@Override public YearMonth parse(String text, Locale locale) throws ParseException { return YearMonth.parse(text); }
@Override public YearMonth parse(String text, Locale locale) throws ParseException { return YearMonth.parse(text); }
@Override protected YearMonth parse(@Nullable final String input) throws Exception { return YearMonth.parse(input); } }
@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); } } }
@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); } } }
@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."); } }
@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; } } }
final YearMonth ym = YearMonth.parse(str); return GregorianCalendar.from(ym.atDay(1).atStartOfDay(ZoneId.systemDefault())); } catch (final DateTimeParseException e) {
@Override public YearMonth parse(final String val) { return YearMonth.parse(val); } }
return YearMonth.parse(string, _formatter); } catch (DateTimeException e) { return _handleDateTimeException(context, e, string);
@Override public YearMonth parse(final String val) { return YearMonth.parse(val); } }
@Override public YearMonth parse(final String val) { return YearMonth.parse(val); } }
@Override public YearMonth getNullableResult(ResultSet rs, int columnIndex) throws SQLException { String value = rs.getString(columnIndex); return value == null ? null : YearMonth.parse(value); }
@Override public YearMonth getNullableResult(ResultSet rs, String columnName) throws SQLException { String value = rs.getString(columnName); return value == null ? null : YearMonth.parse(value); }
@Override public YearMonth getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { String value = cs.getString(columnIndex); return value == null ? null : YearMonth.parse(value); }
return YearMonth.parse(string, _formatter); } catch (DateTimeException e) { return _handleDateTimeException(context, e, string);
/** * <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())); }
@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)))); } }
@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))); } }
@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))); } }