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

x33g5p2x  于2022-01-24 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(188)

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

LocalDate.parse介绍

[英]Obtains an instance of LocalDate from a text string such as 2007-12-23.

The string must represent a valid date and is parsed using org.threeten.bp.format.DateTimeFormatter#ISO_LOCAL_DATE.
[中]从文本字符串(如2007-12-23)获取LocalDate的实例。
字符串必须表示有效日期,并使用org进行解析。三十。英国石油公司。总体安排DateTimeFormatter#ISO#本地#日期。

代码示例

代码示例来源:origin: ThreeTen/threetenbp

/**
 * Obtains an instance of {@code LocalDate} from a text string such as {@code 2007-12-23}.
 * <p>
 * The string must represent a valid date and is parsed using
 * {@link org.threeten.bp.format.DateTimeFormatter#ISO_LOCAL_DATE}.
 *
 * @param text  the text to parse such as "2007-12-23", not null
 * @return the parsed local date, not null
 * @throws DateTimeParseException if the text cannot be parsed
 */
public static LocalDate parse(CharSequence text) {
  return parse(text, DateTimeFormatter.ISO_LOCAL_DATE);
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * Obtains an instance of {@code LocalDate} from a text string such as {@code 2007-12-03}.
 * <p>
 * The string must represent a valid date and is parsed using
 * {@link org.threeten.bp.format.DateTimeFormatter#ISO_LOCAL_DATE}.
 *
 * @param text  the text to parse such as "2007-12-03", not null
 * @return the parsed local date, not null
 * @throws DateTimeParseException if the text cannot be parsed
 */
public static LocalDate parse(CharSequence text) {
  return parse(text, DateTimeFormatter.ISO_LOCAL_DATE);
}

代码示例来源:origin: jeffdcamp/dbtools-android

@Nullable
public static LocalDate dbStringToLocalDate(@Nullable String text) {
  if (text != null && text.length() > 0 && !text.equals("null")) {
    try {
      return LocalDate.parse(text, DB_DATE_FORMATTER310);
    } catch (Exception ex) {
      throw new IllegalArgumentException("Cannot parse date text: " + text, ex);
    }
  } else {
    return null;
  }
}

代码示例来源:origin: com.neotys.ascode/swagger-java-client

@Override
  public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
      case NULL:
        in.nextNull();
        return null;
      default:
        String date = in.nextString();
        return LocalDate.parse(date, formatter);
    }
  }
}

代码示例来源:origin: de.adorsys.multibanking/finapi-adapter

@Override
  public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
      case NULL:
        in.nextNull();
        return null;
      default:
        String date = in.nextString();
        return LocalDate.parse(date, formatter);
    }
  }
}

代码示例来源:origin: shinesolutions/swagger-aem

@Override
  public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
      case NULL:
        in.nextNull();
        return null;
      default:
        String date = in.nextString();
        return LocalDate.parse(date, formatter);
    }
  }
}

代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp

@Override
  protected LocalDate deserialize(String key, DeserializationContext ctxt) throws IOException {
    try {
      return LocalDate.parse(key, DateTimeFormatter.ISO_LOCAL_DATE);
    } catch (DateTimeException e) {
      return _rethrowDateTimeException(ctxt, LocalDate.class, e, key);
    }
  }
}

代码示例来源:origin: AzureAD/azure-activedirectory-library-for-android

@Override
  public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
      case NULL:
        in.nextNull();
        return null;
      default:
        String date = in.nextString();
        return LocalDate.parse(date, formatter);
    }
  }
}

代码示例来源:origin: AzureAD/azure-activedirectory-library-for-android

@Override
  public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
      case NULL:
        in.nextNull();
        return null;
      default:
        String date = in.nextString();
        return LocalDate.parse(date, formatter);
    }
  }
}

代码示例来源:origin: gotify/android

@Override
  public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
      case NULL:
        in.nextNull();
        return null;
      default:
        String date = in.nextString();
        return LocalDate.parse(date, formatter);
    }
  }
}

代码示例来源:origin: com.graphhopper/directions-api-client

@Override
  public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
      case NULL:
        in.nextNull();
        return null;
      default:
        String date = in.nextString();
        return LocalDate.parse(date, formatter);
    }
  }
}

代码示例来源:origin: com.torodb.torod.backends/common

@Override
public ScalarDate toValue(String value) {
  return new LocalDateScalarDate(LocalDate.parse(value));
}

代码示例来源:origin: org.renci.io.swagger/swagger-java-comet-client

@Override
  public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
      case NULL:
        in.nextNull();
        return null;
      default:
        String date = in.nextString();
        return LocalDate.parse(date, formatter);
    }
  }
}

代码示例来源:origin: com.torodb.torod.backends/common

@Override
  public ScalarDate fromJsonValue(JsonString value) {
    return new LocalDateScalarDate(LocalDate.parse(value.getString()));
  }
}

代码示例来源: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: com.github.joschi.jackson/jackson-datatype-threetenbp

return LocalDateTime.ofInstant(Instant.parse(string), ZoneOffset.UTC).toLocalDate();
      } else {
        return LocalDate.parse(string, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
  return LocalDate.parse(string, format);
} catch (DateTimeException e) {
  _rethrowDateTimeException(parser, context, e, string);

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

day = tmp[8] - 48;
} else {
  return LocalDate.parse(new String(tmp, 0, len));
return LocalDate.parse(new String(tmp, 0, len));

相关文章