static Year readExternal(DataInput in) throws IOException { return Year.of(in.readInt()); }
static Year readExternal(DataInput in) throws IOException { return Year.of(in.readInt()); }
/** * Returns a copy of this year with the specified number of years added. * <p> * This instance is immutable and unaffected by this method call. * * @param yearsToAdd the years to add, may be negative * @return a {@code Year} based on this year with the period added, not null * @throws DateTimeException if the result exceeds the supported year range */ public Year plusYears(long yearsToAdd) { if (yearsToAdd == 0) { return this; } return of(YEAR.checkValidIntValue(year + yearsToAdd)); // overflow safe }
/** * Returns a copy of this year with the specified number of years added. * <p> * This instance is immutable and unaffected by this method call. * * @param yearsToAdd the years to add, may be negative * @return a {@code Year} based on this year with the period added, not null * @throws DateTimeException if the result exceeds the supported year range */ public Year plusYears(long yearsToAdd) { if (yearsToAdd == 0) { return this; } return of(YEAR.checkValidIntValue(year + yearsToAdd)); // overflow safe }
/** * Obtains the current year from the specified clock. * <p> * This will query the specified clock to obtain the current year. * Using this method allows the use of an alternate clock for testing. * The alternate clock may be introduced using {@link Clock dependency injection}. * * @param clock the clock to use, not null * @return the current year, not null */ public static Year now(Clock clock) { final LocalDate now = LocalDate.now(clock); // called once return Year.of(now.getYear()); }
/** * Obtains the current year from the specified clock. * <p> * This will query the specified clock to obtain the current year. * Using this method allows the use of an alternate clock for testing. * The alternate clock may be introduced using {@link Clock dependency injection}. * * @param clock the clock to use, not null * @return the current year, not null */ public static Year now(Clock clock) { final LocalDate now = LocalDate.now(clock); // called once return Year.of(now.getYear()); }
zone.year = Year.of(Integer.parseInt(st.nextToken())); if (st.hasMoreTokens()) { parseMonthDayTime(st, zone);
zone.year = Year.of(Integer.parseInt(st.nextToken())); if (st.hasMoreTokens()) { parseMonthDayTime(st, zone);
@Override public Year deserialize(JsonParser parser, DeserializationContext context) throws IOException { JsonToken t = parser.getCurrentToken(); if (t == JsonToken.VALUE_STRING) { String string = parser.getValueAsString().trim(); try { if (_formatter == null) { return Year.parse(string); } return Year.parse(string, _formatter); } catch (DateTimeException e) { _rethrowDateTimeException(parser, context, e, string); } } if (t == JsonToken.VALUE_NUMBER_INT) { return Year.of(parser.getIntValue()); } if (t == JsonToken.VALUE_EMBEDDED_OBJECT) { return (Year) parser.getEmbeddedObject(); } throw context.mappingException("Unexpected token (%s), expected VALUE_STRING or VALUE_NUMBER_INT", parser.getCurrentToken()); } }
temporal = LocalDate.from(temporal); return of(temporal.get(YEAR)); } catch (DateTimeException ex) { throw new DateTimeException("Unable to obtain Year from TemporalAccessor: " +
temporal = LocalDate.from(temporal); return of(temporal.get(YEAR)); } catch (DateTimeException ex) { throw new DateTimeException("Unable to obtain Year from TemporalAccessor: " +