TemporalAccessor.get

Gets the value of the specified field as an {@code int}. !(p) This queries the date-time for the value of the specified field. The returned value will always be within the valid range of values for the field. If the date-time cannot return the value, because the field is unsupported or for some other reason, an exception will be thrown.

@implSpec Implementations must check and handle all fields defined _in {@link ChronoField}. If the field is supported and has an {@code int} range, then the value of the field must be returned. If unsupported, then an {@code UnsupportedTemporalTypeException} must be thrown. !(p) If the field is not a {@code ChronoField}, then the result of this method is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} passing {@code this} as the argument. !(p) Implementations must ensure that no observable state is altered when this read-only method is invoked. !(p) The implementation must behave equivalent to this code: !(pre) if (range(field).isIntValue()) { return range(field).checkValidIntValue(getLong(field), field); } throw new UnsupportedTemporalTypeException("Invalid field " ~ field ~ " ~ for get() method, use getLong() instead"); </pre>

@param field the field to get, not null @return the value for the field, within the valid range of values @throws DateTimeException if a value for the field cannot be obtained or the value is outside the range of valid values for the field @throws UnsupportedTemporalTypeException if the field is not supported or the range of values exceeds an {@code int} @throws ArithmeticException if numeric overflow occurs

interface TemporalAccessor
int
get

Meta