org.threeten.bp.OffsetDateTime.toString()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(2.7k)|赞(0)|评价(0)|浏览(197)

本文整理了Java中org.threeten.bp.OffsetDateTime.toString()方法的一些代码示例,展示了OffsetDateTime.toString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OffsetDateTime.toString()方法的具体详情如下:
包路径:org.threeten.bp.OffsetDateTime
类名称:OffsetDateTime
方法名:toString

OffsetDateTime.toString介绍

[英]Outputs this date-time as a String, such as 2007-12-23T10:15:30+01:00.

The output will be one of the following ISO-8601 formats:

  • yyyy-MM-dd'T'HH:mmXXXXX
  • yyyy-MM-dd'T'HH:mm:ssXXXXX
  • yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX
  • yyyy-MM-dd'T'HH:mm:ss.SSSSSSXXXXX
  • yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSXXXXX

The format used will be the shortest that outputs the full value of the time where the omitted parts are implied to be zero.
[中]以字符串形式输出此日期时间,例如2007-12-23T10:15:30+01:00。
输出将是以下ISO-8601格式之一:
*yyyy MM dd'HH:mmXXXXX
*yyyy MM dd'HH:MM:ssXXXXX
*yyyy-MM-dd'HH:MM:ss。SSSxxx
*yyyy-MM-dd'HH:MM:ss。SSSSXXXXX
*yyyy-MM-dd'HH:MM:ss。SSSSXXXXX
所使用的格式将是最短的,输出省略部分暗示为零的时间的完整值。

代码示例

代码示例来源:origin: com.uwetrottmann.trakt5/trakt-java

public static GsonBuilder getGsonBuilder() {
  GsonBuilder builder = new GsonBuilder();
  // trakt exclusively uses ISO 8601 date times with milliseconds and time zone offset
  // such as '2011-12-03T10:15:30.000+01:00' or '2011-12-03T10:15:30.000Z'
  builder.registerTypeAdapter(OffsetDateTime.class,
      (JsonDeserializer<OffsetDateTime>) (json, typeOfT, context) -> OffsetDateTime.parse(json.getAsString()));
  builder.registerTypeAdapter(OffsetDateTime.class,
      (JsonSerializer<OffsetDateTime>) (src, typeOfSrc, context) -> new JsonPrimitive(src.toString()));
  // dates are in ISO 8601 format as well
  builder.registerTypeAdapter(LocalDate.class,
      (JsonDeserializer<LocalDate>) (json, typeOfT, context) -> LocalDate.parse(json.getAsString()));
  // privacy
  builder.registerTypeAdapter(ListPrivacy.class,
      (JsonDeserializer<ListPrivacy>) (json, typeOfT, context) -> ListPrivacy.fromValue(json.getAsString()));
  // rating
  builder.registerTypeAdapter(Rating.class,
      (JsonDeserializer<Rating>) (json, typeOfT, context) -> Rating.fromValue(json.getAsInt()));
  builder.registerTypeAdapter(Rating.class,
      (JsonSerializer<Rating>) (src, typeOfSrc, context) -> new JsonPrimitive(src.value));
  // sort by
  builder.registerTypeAdapter(SortBy.class,
      (JsonDeserializer<SortBy>) (json, typeOfT, context) -> SortBy.fromValue(json.getAsString()));
  // sort how
  builder.registerTypeAdapter(SortHow.class,
      (JsonDeserializer<SortHow>) (json, typeOfT, context) -> SortHow.fromValue(json.getAsString()));
  // status
  builder.registerTypeAdapter(Status.class,
      (JsonDeserializer<Status>) (json, typeOfT, context) -> Status.fromValue(json.getAsString()));
  return builder;
}

代码示例来源:origin: XeroAPI/Xero-Java

System.out.println(invModified.toString());

代码示例来源:origin: ngs-doo/dsl-json

} else if (year > 9999) {
  sw.writeByte(JsonWriter.QUOTE);
  sw.writeAscii(value.toString());
  sw.writeByte(JsonWriter.QUOTE);
  return;

相关文章