Package org.joda.time.field
Class LenientDateTimeField
java.lang.Object
org.joda.time.DateTimeField
org.joda.time.field.DelegatedDateTimeField
org.joda.time.field.LenientDateTimeField
- All Implemented Interfaces:
Serializable
Converts a strict DateTimeField into a lenient one. By being lenient, the
set method accepts out of bounds values, performing an addition instead.
LenientDateTimeField is thread-safe and immutable.
- Since:
- 1.0
- Author:
- Brian S O'Neill
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
LenientDateTimeField
(DateTimeField field, Chronology base) -
Method Summary
Modifier and TypeMethodDescriptionstatic DateTimeField
getInstance
(DateTimeField field, Chronology base) Returns a lenient version of the given field.final boolean
Returns true if the set method is lenient.long
set
(long instant, int value) Set values which may be out of bounds by adding the difference between the new value and the current value.Methods inherited from class org.joda.time.field.DelegatedDateTimeField
add, add, add, addWrapField, addWrapField, addWrapPartial, get, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsText, getAsText, getAsText, getAsText, getAsText, getDifference, getDifferenceAsLong, getDurationField, getLeapAmount, getLeapDurationField, getMaximumShortTextLength, getMaximumTextLength, getMaximumValue, getMaximumValue, getMaximumValue, getMaximumValue, getMinimumValue, getMinimumValue, getMinimumValue, getMinimumValue, getName, getRangeDurationField, getType, getWrappedField, isLeap, isSupported, remainder, roundCeiling, roundFloor, roundHalfCeiling, roundHalfEven, roundHalfFloor, set, set, set, set, toString
Methods inherited from class org.joda.time.DateTimeField
setExtended
-
Constructor Details
-
LenientDateTimeField
-
-
Method Details
-
getInstance
Returns a lenient version of the given field. If it is already lenient, then it is returned as-is. Otherwise, a new LenientDateTimeField is returned.- Parameters:
field
- the field, null returns nullbase
- the chronology, not null- Returns:
- the field. may be null
-
isLenient
public final boolean isLenient()Description copied from class:DateTimeField
Returns true if the set method is lenient. If so, it accepts values that are out of bounds. For example, a lenient day of month field accepts 32 for January, converting it to February 1.- Overrides:
isLenient
in classDelegatedDateTimeField
- Returns:
- true if this field is lenient
-
set
public long set(long instant, int value) Set values which may be out of bounds by adding the difference between the new value and the current value.- Overrides:
set
in classDelegatedDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to set invalue
- the value to set, in the units of the field- Returns:
- the updated milliseconds
-