本文整理了Java中java.time.YearMonth.parse()
方法的一些代码示例,展示了YearMonth.parse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YearMonth.parse()
方法的具体详情如下:
包路径:java.time.YearMonth
类名称:YearMonth
方法名:parse
[英]Obtains an instance of YearMonth from a text string such as 2007-12.
The string must represent a valid year-month. The format must be yyyy-MM. Years outside the range 0000 to 9999 must be prefixed by the plus or minus symbol.
[中]从文本字符串(如2007-12)获取YearMonth的实例。
字符串必须表示有效的年和月。格式必须为yyyy-MM。0000到9999之间的年份必须以加号或减号作为前缀。
代码示例来源:origin: spring-projects/spring-framework
@Override
public YearMonth parse(String text, Locale locale) throws ParseException {
return YearMonth.parse(text);
}
代码示例来源:origin: org.springframework/spring-context
@Override
public YearMonth parse(String text, Locale locale) throws ParseException {
return YearMonth.parse(text);
}
代码示例来源:origin: dropwizard/dropwizard
@Override
protected YearMonth parse(@Nullable final String input) throws Exception {
return YearMonth.parse(input);
}
}
代码示例来源:origin: prestodb/presto
@Override
protected YearMonth deserialize(String key, DeserializationContext ctxt) throws IOException {
try {
return YearMonth.parse(key, FORMATTER);
} catch (DateTimeException e) {
return _handleDateTimeException(ctxt, YearMonth.class, e, key);
}
}
}
代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-jsr310
@Override
protected YearMonth deserialize(String key, DeserializationContext ctxt) throws IOException {
try {
return YearMonth.parse(key, FORMATTER);
} catch (DateTimeException e) {
return _handleDateTimeException(ctxt, YearMonth.class, e, key);
}
}
}
代码示例来源:origin: bootique/bootique
@Override
public YearMonth deserialize(JsonParser parser, DeserializationContext context) throws IOException {
if (parser.hasToken(JsonToken.VALUE_STRING)) {
String string = parser.getText().trim();
if (string.length() == 0) {
return null;
}
return YearMonth.parse(string, _formatter);
}
throw context.wrongTokenException(parser, JsonToken.START_ARRAY, "Expected array or string.");
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
@Override
public YearMonth fromString(final String str) {
try {
return YearMonth.parse(str);
} catch (final DateTimeParseException ex) {
final ConversionException exception = new ConversionException("Cannot parse value as year month", ex);
exception.add("value", str);
throw exception;
}
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
final YearMonth ym = YearMonth.parse(str);
return GregorianCalendar.from(ym.atDay(1).atStartOfDay(ZoneId.systemDefault()));
} catch (final DateTimeParseException e) {
代码示例来源:origin: apache/tinkerpop
@Override
public YearMonth parse(final String val) {
return YearMonth.parse(val);
}
}
代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-jsr310
return YearMonth.parse(string, _formatter);
} catch (DateTimeException e) {
return _handleDateTimeException(context, e, string);
代码示例来源:origin: apache/tinkerpop
@Override
public YearMonth parse(final String val) {
return YearMonth.parse(val);
}
}
代码示例来源:origin: apache/tinkerpop
@Override
public YearMonth parse(final String val) {
return YearMonth.parse(val);
}
}
代码示例来源:origin: org.mybatis/mybatis
@Override
public YearMonth getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
String value = rs.getString(columnIndex);
return value == null ? null : YearMonth.parse(value);
}
代码示例来源:origin: org.mybatis/mybatis
@Override
public YearMonth getNullableResult(ResultSet rs, String columnName) throws SQLException {
String value = rs.getString(columnName);
return value == null ? null : YearMonth.parse(value);
}
代码示例来源:origin: org.mybatis/mybatis
@Override
public YearMonth getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
String value = cs.getString(columnIndex);
return value == null ? null : YearMonth.parse(value);
}
代码示例来源:origin: prestodb/presto
return YearMonth.parse(string, _formatter);
} catch (DateTimeException e) {
return _handleDateTimeException(context, e, string);
代码示例来源:origin: pholser/junit-quickcheck
/**
* <p>Tells this generator to produce values within a specified
* {@linkplain InRange#min() minimum} and/or {@linkplain InRange#max()
* maximum}, inclusive, with uniform distribution.</p>
*
* <p>If an endpoint of the range is not specified, the generator will use
* dates with values of either {@code YearMonth(Year#MIN_VALUE, 1)} or
* {@code YearMonth(Year#MAX_VALUE, 12)} as appropriate.</p>
*
* <p>{@link InRange#format()} describes
* {@linkplain DateTimeFormatter#ofPattern(String) how the generator is to
* interpret the range's endpoints}.</p>
*
* @param range annotation that gives the range's constraints
*/
public void configure(InRange range) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(range.format());
if (!defaultValueOf(InRange.class, "min").equals(range.min()))
min = YearMonth.parse(range.min(), formatter);
if (!defaultValueOf(InRange.class, "max").equals(range.max()))
max = YearMonth.parse(range.max(), formatter);
if (min.compareTo(max) > 0)
throw new IllegalArgumentException(String.format("bad range, %s > %s", range.min(), range.max()));
}
代码示例来源:origin: pholser/junit-quickcheck
@Property public void shouldHold(
@InRange(min = "1776/04", max = "1976/12", format = "yyyy/MM") YearMonth m) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM");
assertThat(
m,
allOf(
greaterThanOrEqualTo(YearMonth.parse("1776/04", formatter)),
lessThanOrEqualTo(YearMonth.parse("1976/12", formatter))));
}
}
代码示例来源:origin: pholser/junit-quickcheck
@Property public void shouldHold(
@InRange(max = "1976/12", format = "yyyy/MM") YearMonth m) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM");
assertThat(m, lessThanOrEqualTo(YearMonth.parse("1976/12", formatter)));
}
}
代码示例来源:origin: pholser/junit-quickcheck
@Property public void shouldHold(
@InRange(min = "1976/12", format = "yyyy/MM") YearMonth m) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM");
assertThat(m, greaterThanOrEqualTo(YearMonth.parse("1976/12", formatter)));
}
}
内容来源于网络,如有侵权,请联系作者删除!