/** * Checks if the field type specified is supported by this * local time and chronology. * This can be used to avoid exceptions in {@link #get(DateTimeFieldType)}. * * @param type a field type, usually obtained from DateTimeFieldType * @return true if the field type is supported */ public boolean isSupported(DateTimeFieldType type) { if (type == null) { return false; } if (isSupported(type.getDurationType()) == false) { return false; } DurationFieldType range = type.getRangeDurationType(); return (isSupported(range) || range == DurationFieldType.days()); }
/** * Checks if the field type specified is supported by this * local time and chronology. * This can be used to avoid exceptions in {@link #get(DateTimeFieldType)}. * * @param type a field type, usually obtained from DateTimeFieldType * @return true if the field type is supported */ public boolean isSupported(DateTimeFieldType type) { if (type == null) { return false; } if (isSupported(type.getDurationType()) == false) { return false; } DurationFieldType range = type.getRangeDurationType(); return (isSupported(range) || range == DurationFieldType.days()); }
/** * Gets the property object for the specified type, which contains * many useful methods. * * @param fieldType the field type to get the chronology for * @return the property object * @throws IllegalArgumentException if the field is null or unsupported */ public Property property(DateTimeFieldType fieldType) { if (fieldType == null) { throw new IllegalArgumentException("The DateTimeFieldType must not be null"); } if (isSupported(fieldType) == false) { throw new IllegalArgumentException("Field '" + fieldType + "' is not supported"); } return new Property(this, fieldType.getField(getChronology())); }
/** * Gets the property object for the specified type, which contains * many useful methods. * * @param fieldType the field type to get the chronology for * @return the property object * @throws IllegalArgumentException if the field is null or unsupported */ public Property property(DateTimeFieldType fieldType) { if (fieldType == null) { throw new IllegalArgumentException("The DateTimeFieldType must not be null"); } if (isSupported(fieldType) == false) { throw new IllegalArgumentException("Field '" + fieldType + "' is not supported"); } return new Property(this, fieldType.getField(getChronology())); }
/** * Get the value of one of the fields of time. * <p> * This method gets the value of the specified field. * For example: * <pre> * DateTime dt = new DateTime(); * int hourOfDay = dt.get(DateTimeFieldType.hourOfDay()); * </pre> * * @param fieldType a field type, usually obtained from DateTimeFieldType, not null * @return the value of that field * @throws IllegalArgumentException if the field type is null */ public int get(DateTimeFieldType fieldType) { if (fieldType == null) { throw new IllegalArgumentException("The DateTimeFieldType must not be null"); } if (isSupported(fieldType) == false) { throw new IllegalArgumentException("Field '" + fieldType + "' is not supported"); } return fieldType.getField(getChronology()).get(getLocalMillis()); }
/** * Get the value of one of the fields of time. * <p> * This method gets the value of the specified field. * For example: * <pre> * DateTime dt = new DateTime(); * int hourOfDay = dt.get(DateTimeFieldType.hourOfDay()); * </pre> * * @param fieldType a field type, usually obtained from DateTimeFieldType, not null * @return the value of that field * @throws IllegalArgumentException if the field type is null */ public int get(DateTimeFieldType fieldType) { if (fieldType == null) { throw new IllegalArgumentException("The DateTimeFieldType must not be null"); } if (isSupported(fieldType) == false) { throw new IllegalArgumentException("Field '" + fieldType + "' is not supported"); } return fieldType.getField(getChronology()).get(getLocalMillis()); }
/** * Returns a copy of this time with the specified field set * to a new value. * <p> * For example, if the field type is <code>hourOfDay</code> then the hour of day * field would be changed in the returned instance. * If the field type is null, then <code>this</code> is returned. * <p> * These lines are equivalent: * <pre> * LocalTime updated = dt.withHourOfDay(6); * LocalTime updated = dt.withField(DateTimeFieldType.hourOfDay(), 6); * </pre> * * @param fieldType the field type to set, not null * @param value the value to set * @return a copy of this time with the field set * @throws IllegalArgumentException if the value is null or invalid */ public LocalTime withField(DateTimeFieldType fieldType, int value) { if (fieldType == null) { throw new IllegalArgumentException("Field must not be null"); } if (isSupported(fieldType) == false) { throw new IllegalArgumentException("Field '" + fieldType + "' is not supported"); } long instant = fieldType.getField(getChronology()).set(getLocalMillis(), value); return withLocalMillis(instant); }
throw new IllegalArgumentException("Field must not be null"); if (isSupported(fieldType) == false) { throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");
/** * Returns a copy of this time with the specified field set * to a new value. * <p> * For example, if the field type is <code>hourOfDay</code> then the hour of day * field would be changed in the returned instance. * If the field type is null, then <code>this</code> is returned. * <p> * These lines are equivalent: * <pre> * LocalTime updated = dt.withHourOfDay(6); * LocalTime updated = dt.withField(DateTimeFieldType.hourOfDay(), 6); * </pre> * * @param fieldType the field type to set, not null * @param value the value to set * @return a copy of this time with the field set * @throws IllegalArgumentException if the value is null or invalid */ public LocalTime withField(DateTimeFieldType fieldType, int value) { if (fieldType == null) { throw new IllegalArgumentException("Field must not be null"); } if (isSupported(fieldType) == false) { throw new IllegalArgumentException("Field '" + fieldType + "' is not supported"); } long instant = fieldType.getField(getChronology()).set(getLocalMillis(), value); return withLocalMillis(instant); }
throw new IllegalArgumentException("Field must not be null"); if (isSupported(fieldType) == false) { throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");
/** * Checks if the field type specified is supported by this * local time and chronology. * This can be used to avoid exceptions in {@link #get(DateTimeFieldType)}. * * @param type a field type, usually obtained from DateTimeFieldType * @return true if the field type is supported */ public boolean isSupported(DateTimeFieldType type) { if (type == null) { return false; } if (isSupported(type.getDurationType()) == false) { return false; } DurationFieldType range = type.getRangeDurationType(); return (isSupported(range) || range == DurationFieldType.days()); }
/** * Gets the property object for the specified type, which contains * many useful methods. * * @param fieldType the field type to get the chronology for * @return the property object * @throws IllegalArgumentException if the field is null or unsupported */ public Property property(DateTimeFieldType fieldType) { if (fieldType == null) { throw new IllegalArgumentException("The DateTimeFieldType must not be null"); } if (isSupported(fieldType) == false) { throw new IllegalArgumentException("Field '" + fieldType + "' is not supported"); } return new Property(this, fieldType.getField(getChronology())); }
/** * Get the value of one of the fields of time. * <p> * This method gets the value of the specified field. * For example: * <pre> * DateTime dt = new DateTime(); * int hourOfDay = dt.get(DateTimeFieldType.hourOfDay()); * </pre> * * @param fieldType a field type, usually obtained from DateTimeFieldType, not null * @return the value of that field * @throws IllegalArgumentException if the field type is null */ public int get(DateTimeFieldType fieldType) { if (fieldType == null) { throw new IllegalArgumentException("The DateTimeFieldType must not be null"); } if (isSupported(fieldType) == false) { throw new IllegalArgumentException("Field '" + fieldType + "' is not supported"); } return fieldType.getField(getChronology()).get(getLocalMillis()); }
/** * Returns a copy of this time with the specified field set * to a new value. * <p> * For example, if the field type is <code>hourOfDay</code> then the hour of day * field would be changed in the returned instance. * If the field type is null, then <code>this</code> is returned. * <p> * These lines are equivalent: * <pre> * LocalTime updated = dt.withHourOfDay(6); * LocalTime updated = dt.withField(DateTimeFieldType.hourOfDay(), 6); * </pre> * * @param fieldType the field type to set, not null * @param value the value to set * @return a copy of this time with the field set * @throws IllegalArgumentException if the value is null or invalid */ public LocalTime withField(DateTimeFieldType fieldType, int value) { if (fieldType == null) { throw new IllegalArgumentException("Field must not be null"); } if (isSupported(fieldType) == false) { throw new IllegalArgumentException("Field '" + fieldType + "' is not supported"); } long instant = fieldType.getField(getChronology()).set(getLocalMillis(), value); return withLocalMillis(instant); }
throw new IllegalArgumentException("Field must not be null"); if (isSupported(fieldType) == false) { throw new IllegalArgumentException("Field '" + fieldType + "' is not supported");
/** * Checks if the field type specified is supported by this * local time and chronology. * This can be used to avoid exceptions in {@link #get(DateTimeFieldType)}. * * @param type a field type, usually obtained from DateTimeFieldType * @return true if the field type is supported */ public boolean isSupported(DateTimeFieldType type) { if (type == null) { return false; } if (isSupported(type.getDurationType()) == false) { return false; } DurationFieldType range = type.getRangeDurationType(); return (isSupported(range) || range == DurationFieldType.days()); }
/** * Checks if the field type specified is supported by this * local time and chronology. * This can be used to avoid exceptions in {@link #get(DateTimeFieldType)}. * * @param type a field type, usually obtained from DateTimeFieldType * @return true if the field type is supported */ public boolean isSupported(DateTimeFieldType type) { if (type == null) { return false; } if (isSupported(type.getDurationType()) == false) { return false; } DurationFieldType range = type.getRangeDurationType(); return (isSupported(range) || range == DurationFieldType.days()); }
/** * Checks if the field type specified is supported by this * local time and chronology. * This can be used to avoid exceptions in {@link #get(DateTimeFieldType)}. * * @param type a field type, usually obtained from DateTimeFieldType * @return true if the field type is supported */ public boolean isSupported(DateTimeFieldType type) { if (type == null) { return false; } if (isSupported(type.getDurationType()) == false) { return false; } DurationFieldType range = type.getRangeDurationType(); return (isSupported(range) || range == DurationFieldType.days()); }
/** * Gets the property object for the specified type, which contains * many useful methods. * * @param fieldType the field type to get the chronology for * @return the property object * @throws IllegalArgumentException if the field is null or unsupported */ public Property property(DateTimeFieldType fieldType) { if (fieldType == null) { throw new IllegalArgumentException("The DateTimeFieldType must not be null"); } if (isSupported(fieldType) == false) { throw new IllegalArgumentException("Field '" + fieldType + "' is not supported"); } return new Property(this, fieldType.getField(getChronology())); }
/** * Gets the property object for the specified type, which contains * many useful methods. * * @param fieldType the field type to get the chronology for * @return the property object * @throws IllegalArgumentException if the field is null or unsupported */ public Property property(DateTimeFieldType fieldType) { if (fieldType == null) { throw new IllegalArgumentException("The DateTimeFieldType must not be null"); } if (isSupported(fieldType) == false) { throw new IllegalArgumentException("Field '" + fieldType + "' is not supported"); } return new Property(this, fieldType.getField(getChronology())); }