@SuppressWarnings( "BooleanMethodIsAlwaysInverted" ) private boolean supports( TemporalField field ) { if ( field.isDateBased() ) { return supportsDate(); } if ( field.isTimeBased() ) { return supportsTime(); } throw new IllegalStateException( "Fields should be either date based or time based" ); }
DateTimeBuilder assignToSubBuilders( TemporalFields field, AnyValue value ) { if ( field == TemporalFields.date || field.field != null && field.field.isDateBased() ) { if ( date == null ) { date = new ConstructDate(); } date = date.assign( field, value ); } else if ( field == TemporalFields.time || field.field != null && field.field.isTimeBased() ) { if ( time == null ) { time = new ConstructTime(); } time.assign( field, value ); } else { throw new IllegalStateException( "This method should not be used for any fields the DateBuilder or TimeBuilder can't handle" ); } return this; } }
@Override public boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { return field.isDateBased() || field.isTimeBased(); } return field != null && field.isSupportedBy(this); }
public boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { return field.isTimeBased();
public boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { return field.isTimeBased() || field == OFFSET_SECONDS;
@SuppressWarnings( "BooleanMethodIsAlwaysInverted" ) private boolean supports( TemporalField field ) { if ( field.isDateBased() ) { return supportsDate(); } if ( field.isTimeBased() ) { return supportsTime(); } throw new IllegalStateException( "Fields should be either date based or time based" ); }
@Override public long getLong(TemporalField field) { if (field instanceof ChronoField) { return (field.isTimeBased() ? time.getLong(field) : date.getLong(field)); } return field.getFrom(this); }
@Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { return (field.isTimeBased() ? time.range(field) : date.range(field)); } return field.rangeRefinedBy(this); }
public boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { return field.isDateBased() || field.isTimeBased();
/** * Gets the value of the specified field from this date-time as a {@code long}. * <p> * This queries this date-time for the value for the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. * <p> * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time. * All other {@code ChronoField} instances will throw a {@code DateTimeException}. * <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. Whether the value can be obtained, * and what the value represents, is determined by the field. * * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained * @throws ArithmeticException if numeric overflow occurs */ @Override public long getLong(TemporalField field) { if (field instanceof ChronoField) { return (field.isTimeBased() ? time.getLong(field) : date.getLong(field)); } return field.getFrom(this); }
/** * Gets the range of valid values for the specified field. * <p> * The range object expresses the minimum and maximum valid values for a field. * This date-time is used to enhance the accuracy of the returned range. * If it is not possible to return the range, because the field is not supported * or for some other reason, an exception is thrown. * <p> * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. * All other {@code ChronoField} instances will throw a {@code DateTimeException}. * <p> * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} * passing {@code this} as the argument. * Whether the range can be obtained is determined by the field. * * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained */ @Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { return (field.isTimeBased() ? time.range(field) : date.range(field)); } return field.rangeRefinedBy(this); }
public int get(TemporalField field) { if (field instanceof ChronoField) { return (field.isTimeBased() ? time.get(field) : date.get(field));
@Override public int get(TemporalField field) { if (field instanceof ChronoField) { return (field.isTimeBased() ? time.get(field) : date.get(field)); } return range(field).checkValidIntValue(getLong(field), field); }
DateTimeBuilder assignToSubBuilders( TemporalFields field, AnyValue value ) { if ( field == TemporalFields.date || field.field != null && field.field.isDateBased() ) { if ( date == null ) { date = new ConstructDate(); } date = date.assign( field, value ); } else if ( field == TemporalFields.time || field.field != null && field.field.isTimeBased() ) { if ( time == null ) { time = new ConstructTime(); } time.assign( field, value ); } else { throw new IllegalStateException( "This method should not be used for any fields the DateBuilder or TimeBuilder can't handle" ); } return this; } }
@Override public ChronoLocalDateTimeImpl<D> with(TemporalField field, long newValue) { if (field instanceof ChronoField) { if (field.isTimeBased()) { return with(date, time.with(field, newValue)); } else { return with(date.with(field, newValue), time); } } return date.getChronology().ensureChronoLocalDateTime(field.adjustInto(this, newValue)); }
public LocalDateTime with(TemporalField field, long newValue) { if (field instanceof ChronoField) { if (field.isTimeBased()) { return with(date, time.with(field, newValue)); } else {