public class DelegatedDateTimeField extends DateTimeField implements java.io.Serializable
DelegatedDateTimeField
delegates each method call to the
date time field it wraps.
DelegatedDateTimeField is thread-safe and immutable, and its subclasses must be as well.
DecoratedDateTimeField
,
Serialized FormConstructor and Description |
---|
DelegatedDateTimeField(DateTimeField field)
Constructor.
|
DelegatedDateTimeField(DateTimeField field,
DateTimeFieldType type)
Constructor.
|
DelegatedDateTimeField(DateTimeField field,
DurationField rangeField,
DateTimeFieldType type)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
long |
add(long instant,
int value)
Adds a value (which may be negative) to the millis value,
overflowing into larger fields if necessary.
|
long |
add(long instant,
long value)
Adds a value (which may be negative) to the millis value,
overflowing into larger fields if necessary.
|
int[] |
add(ReadablePartial instant,
int fieldIndex,
int[] values,
int valueToAdd)
Adds a value (which may be negative) to the partial instant,
throwing an exception if the maximum size of the instant is reached.
|
long |
addWrapField(long instant,
int value)
Adds a value (which may be negative) to the millis value,
wrapping within this field.
|
int[] |
addWrapField(ReadablePartial instant,
int fieldIndex,
int[] values,
int valueToAdd)
Adds a value (which may be negative) to the partial instant,
wrapping within this field.
|
int[] |
addWrapPartial(ReadablePartial instant,
int fieldIndex,
int[] values,
int valueToAdd)
Adds a value (which may be negative) to the partial instant,
wrapping the whole partial if the maximum size of the partial is reached.
|
int |
get(long instant)
Get the value of this field from the milliseconds.
|
java.lang.String |
getAsShortText(int fieldValue,
java.util.Locale locale)
Get the human-readable, short text value of this field from the field value.
|
java.lang.String |
getAsShortText(long instant)
Get the human-readable, short text value of this field from the
milliseconds.
|
java.lang.String |
getAsShortText(long instant,
java.util.Locale locale)
Get the human-readable, short text value of this field from the
milliseconds.
|
java.lang.String |
getAsShortText(ReadablePartial partial,
int fieldValue,
java.util.Locale locale)
Get the human-readable, short text value of this field from a partial instant.
|
java.lang.String |
getAsShortText(ReadablePartial partial,
java.util.Locale locale)
Get the human-readable, short text value of this field from a partial instant.
|
java.lang.String |
getAsText(int fieldValue,
java.util.Locale locale)
Get the human-readable, text value of this field from the field value.
|
java.lang.String |
getAsText(long instant)
Get the human-readable, text value of this field from the milliseconds.
|
java.lang.String |
getAsText(long instant,
java.util.Locale locale)
Get the human-readable, text value of this field from the milliseconds.
|
java.lang.String |
getAsText(ReadablePartial partial,
int fieldValue,
java.util.Locale locale)
Get the human-readable, text value of this field from a partial instant.
|
java.lang.String |
getAsText(ReadablePartial partial,
java.util.Locale locale)
Get the human-readable, text value of this field from a partial instant.
|
int |
getDifference(long minuendInstant,
long subtrahendInstant)
Computes the difference between two instants, as measured in the units
of this field.
|
long |
getDifferenceAsLong(long minuendInstant,
long subtrahendInstant)
Computes the difference between two instants, as measured in the units
of this field.
|
DurationField |
getDurationField()
Returns the duration per unit value of this field.
|
int |
getLeapAmount(long instant)
Gets the amount by which this field is 'leap' for the specified instant.
|
DurationField |
getLeapDurationField()
If this field were to leap, then it would be in units described by the
returned duration.
|
int |
getMaximumShortTextLength(java.util.Locale locale)
Get the maximum short text value for this field.
|
int |
getMaximumTextLength(java.util.Locale locale)
Get the maximum text value for this field.
|
int |
getMaximumValue()
Get the maximum allowable value for this field.
|
int |
getMaximumValue(long instant)
Get the maximum value for this field evaluated at the specified time.
|
int |
getMaximumValue(ReadablePartial instant)
Get the maximum value for this field evaluated at the specified time.
|
int |
getMaximumValue(ReadablePartial instant,
int[] values)
Get the maximum value for this field using the partial instant and
the specified values.
|
int |
getMinimumValue()
Get the minimum allowable value for this field.
|
int |
getMinimumValue(long instant)
Get the minimum value for this field evaluated at the specified time.
|
int |
getMinimumValue(ReadablePartial instant)
Get the minimum value for this field evaluated at the specified time.
|
int |
getMinimumValue(ReadablePartial instant,
int[] values)
Get the minimum value for this field using the partial instant and
the specified values.
|
java.lang.String |
getName()
Get the name of the field.
|
DurationField |
getRangeDurationField()
Returns the range duration of this field.
|
DateTimeFieldType |
getType()
Get the type of the field.
|
DateTimeField |
getWrappedField()
Gets the wrapped date time field.
|
boolean |
isLeap(long instant)
Returns whether this field is 'leap' for the specified instant.
|
boolean |
isLenient()
Returns true if the set method is lenient.
|
boolean |
isSupported()
Returns true if this field is supported.
|
long |
remainder(long instant)
Returns the fractional duration milliseconds of this field.
|
long |
roundCeiling(long instant)
Round to the highest whole unit of this field.
|
long |
roundFloor(long instant)
Round to the lowest whole unit of this field.
|
long |
roundHalfCeiling(long instant)
Round to the nearest whole unit of this field.
|
long |
roundHalfEven(long instant)
Round to the nearest whole unit of this field.
|
long |
roundHalfFloor(long instant)
Round to the nearest whole unit of this field.
|
long |
set(long instant,
int value)
Sets a value in the milliseconds supplied.
|
long |
set(long instant,
java.lang.String text)
Sets a value in the milliseconds supplied from a human-readable, text value.
|
long |
set(long instant,
java.lang.String text,
java.util.Locale locale)
Sets a value in the milliseconds supplied from a human-readable, text value.
|
int[] |
set(ReadablePartial instant,
int fieldIndex,
int[] values,
int newValue)
Sets a value using the specified partial instant.
|
int[] |
set(ReadablePartial instant,
int fieldIndex,
int[] values,
java.lang.String text,
java.util.Locale locale)
Sets a value in the milliseconds supplied from a human-readable, text value.
|
java.lang.String |
toString()
Get a suitable debug string.
|
setExtended
public DelegatedDateTimeField(DateTimeField field)
field
- the field being decoratedpublic DelegatedDateTimeField(DateTimeField field, DateTimeFieldType type)
field
- the field being decoratedtype
- the field type overridepublic DelegatedDateTimeField(DateTimeField field, DurationField rangeField, DateTimeFieldType type)
field
- the field being decoratedrangeField
- the range field, null to derivetype
- the field type overridepublic final DateTimeField getWrappedField()
public DateTimeFieldType getType()
DateTimeField
getType
in class DateTimeField
public java.lang.String getName()
DateTimeField
By convention, names follow a pattern of "dddOfRrr", where "ddd" represents the (singular) duration unit field name and "Rrr" represents the (singular) duration range field name. If the range field is not applicable, then the name of the field is simply the (singular) duration field name.
getName
in class DateTimeField
public boolean isSupported()
DateTimeField
isSupported
in class DateTimeField
public boolean isLenient()
DateTimeField
isLenient
in class DateTimeField
public int get(long instant)
DateTimeField
get
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to querypublic java.lang.String getAsText(long instant, java.util.Locale locale)
DateTimeField
getAsText
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to querylocale
- the locale to use for selecting a text symbol, null for defaultpublic java.lang.String getAsText(long instant)
DateTimeField
getAsText
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to querypublic java.lang.String getAsText(ReadablePartial partial, int fieldValue, java.util.Locale locale)
DateTimeField
getAsText
in class DateTimeField
partial
- the partial instant to queryfieldValue
- the field value of this field, provided for performancelocale
- the locale to use for selecting a text symbol, null for defaultpublic java.lang.String getAsText(ReadablePartial partial, java.util.Locale locale)
DateTimeField
getAsText
in class DateTimeField
partial
- the partial instant to querylocale
- the locale to use for selecting a text symbol, null for defaultpublic java.lang.String getAsText(int fieldValue, java.util.Locale locale)
DateTimeField
getAsText
in class DateTimeField
fieldValue
- the numeric value to convert to textlocale
- the locale to use for selecting a text symbol, null for defaultpublic java.lang.String getAsShortText(long instant, java.util.Locale locale)
DateTimeField
getAsShortText
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to querylocale
- the locale to use for selecting a text symbol, null for defaultpublic java.lang.String getAsShortText(long instant)
DateTimeField
getAsShortText
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to querypublic java.lang.String getAsShortText(ReadablePartial partial, int fieldValue, java.util.Locale locale)
DateTimeField
getAsShortText
in class DateTimeField
partial
- the partial instant to queryfieldValue
- the field value of this field, provided for performancelocale
- the locale to use for selecting a text symbol, null for defaultpublic java.lang.String getAsShortText(ReadablePartial partial, java.util.Locale locale)
DateTimeField
getAsShortText
in class DateTimeField
partial
- the partial instant to querylocale
- the locale to use for selecting a text symbol, null for defaultpublic java.lang.String getAsShortText(int fieldValue, java.util.Locale locale)
DateTimeField
getAsShortText
in class DateTimeField
fieldValue
- the numeric value to convert to textlocale
- the locale to use for selecting a text symbol, null for defaultpublic long add(long instant, int value)
DateTimeField
The value will be added to this field. If the value is too large to be added solely to this field, larger fields will increase as required. Smaller fields should be unaffected, except where the result would be an invalid value for a smaller field. In this case the smaller field is adjusted to be in range.
For example, in the ISO chronology:
2000-08-20 add six months is 2001-02-20
2000-08-20 add twenty months is 2002-04-20
2000-08-20 add minus nine months is 1999-11-20
2001-01-31 add one month is 2001-02-28
2001-01-31 add two months is 2001-03-31
add
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to add tovalue
- the value to add, in the units of the fieldpublic long add(long instant, long value)
DateTimeField
add
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to add tovalue
- the long value to add, in the units of the fieldDateTimeField.add(long,int)
public int[] add(ReadablePartial instant, int fieldIndex, int[] values, int valueToAdd)
DateTimeField
The value will be added to this field, overflowing into larger fields if necessary. Smaller fields should be unaffected, except where the result would be an invalid value for a smaller field. In this case the smaller field is adjusted to be in range.
Partial instants only contain some fields. This may result in a maximum possible value, such as TimeOfDay being limited to 23:59:59:999. If this limit is breached by the add an exception is thrown.
For example, in the ISO chronology:
2000-08-20 add six months is 2000-02-20
2000-08-20 add twenty months is 2000-04-20
2000-08-20 add minus nine months is 2000-11-20
2001-01-31 add one month is 2001-02-28
2001-01-31 add two months is 2001-03-31
add
in class DateTimeField
instant
- the partial instantfieldIndex
- the index of this field in the instantvalues
- the values of the partial instant which should be updatedvalueToAdd
- the value to add, in the units of the fieldpublic int[] addWrapPartial(ReadablePartial instant, int fieldIndex, int[] values, int valueToAdd)
DateTimeField
The value will be added to this field, overflowing into larger fields if necessary. Smaller fields should be unaffected, except where the result would be an invalid value for a smaller field. In this case the smaller field is adjusted to be in range.
Partial instants only contain some fields. This may result in a maximum possible value, such as TimeOfDay normally being limited to 23:59:59:999. If ths limit is reached by the addition, this method will wrap back to 00:00:00.000. In fact, you would generally only use this method for classes that have a limitation such as this.
For example, in the ISO chronology:
10:20:30 add 20 minutes is 10:40:30
10:20:30 add 45 minutes is 11:05:30
10:20:30 add 16 hours is 02:20:30
addWrapPartial
in class DateTimeField
instant
- the partial instantfieldIndex
- the index of this field in the partialvalues
- the values of the partial instant which should be updatedvalueToAdd
- the value to add, in the units of the fieldpublic long addWrapField(long instant, int value)
DateTimeField
The value will be added to this field. If the value is too large to be added solely to this field then it wraps. Larger fields are always unaffected. Smaller fields should be unaffected, except where the result would be an invalid value for a smaller field. In this case the smaller field is adjusted to be in range.
For example, in the ISO chronology:
2000-08-20 addWrapField six months is 2000-02-20
2000-08-20 addWrapField twenty months is 2000-04-20
2000-08-20 addWrapField minus nine months is 2000-11-20
2001-01-31 addWrapField one month is 2001-02-28
2001-01-31 addWrapField two months is 2001-03-31
addWrapField
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to add tovalue
- the value to add, in the units of the fieldpublic int[] addWrapField(ReadablePartial instant, int fieldIndex, int[] values, int valueToAdd)
DateTimeField
The value will be added to this field. If the value is too large to be added solely to this field then it wraps. Larger fields are always unaffected. Smaller fields should be unaffected, except where the result would be an invalid value for a smaller field. In this case the smaller field is adjusted to be in range.
For example, in the ISO chronology:
2000-08-20 addWrapField six months is 2000-02-20
2000-08-20 addWrapField twenty months is 2000-04-20
2000-08-20 addWrapField minus nine months is 2000-11-20
2001-01-31 addWrapField one month is 2001-02-28
2001-01-31 addWrapField two months is 2001-03-31
addWrapField
in class DateTimeField
instant
- the partial instantfieldIndex
- the index of this field in the instantvalues
- the values of the partial instant which should be updatedvalueToAdd
- the value to add, in the units of the fieldpublic int getDifference(long minuendInstant, long subtrahendInstant)
DateTimeField
long instant = ... int v = ... int age = getDifference(add(instant, v), instant);The value 'age' is the same as the value 'v'.
getDifference
in class DateTimeField
minuendInstant
- the milliseconds from 1970-01-01T00:00:00Z to
subtract fromsubtrahendInstant
- the milliseconds from 1970-01-01T00:00:00Z to
subtract off the minuendpublic long getDifferenceAsLong(long minuendInstant, long subtrahendInstant)
DateTimeField
long instant = ... long v = ... long age = getDifferenceAsLong(add(instant, v), instant);The value 'age' is the same as the value 'v'.
getDifferenceAsLong
in class DateTimeField
minuendInstant
- the milliseconds from 1970-01-01T00:00:00Z to
subtract fromsubtrahendInstant
- the milliseconds from 1970-01-01T00:00:00Z to
subtract off the minuendpublic long set(long instant, int value)
DateTimeField
The value of this field will be set. If the value is invalid, an exception if thrown.
If setting this field would make other fields invalid, then those fields may be changed. For example if the current date is the 31st January, and the month is set to February, the day would be invalid. Instead, the day would be changed to the closest value - the 28th/29th February as appropriate.
set
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to set invalue
- the value to set, in the units of the fieldpublic long set(long instant, java.lang.String text, java.util.Locale locale)
DateTimeField
If setting this field would make other fields invalid, then those fields may be changed. For example if the current date is the 31st January, and the month is set to February, the day would be invalid. Instead, the day would be changed to the closest value - the 28th/29th February as appropriate.
set
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to set intext
- the text value to setlocale
- the locale to use for selecting a text symbol, null for defaultpublic long set(long instant, java.lang.String text)
DateTimeField
If setting this field would make other fields invalid, then those fields may be changed. For example if the current date is the 31st January, and the month is set to February, the day would be invalid. Instead, the day would be changed to the closest value - the 28th/29th February as appropriate.
set
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to set intext
- the text value to setpublic int[] set(ReadablePartial instant, int fieldIndex, int[] values, int newValue)
DateTimeField
The value of this field (specified by the index) will be set. If the value is invalid, an exception if thrown.
If setting this field would make other fields invalid, then those fields may be changed. For example if the current date is the 31st January, and the month is set to February, the day would be invalid. Instead, the day would be changed to the closest value - the 28th/29th February as appropriate.
set
in class DateTimeField
instant
- the partial instantfieldIndex
- the index of this field in the instantvalues
- the values of the partial instant which should be updatednewValue
- the value to set, in the units of the fieldpublic int[] set(ReadablePartial instant, int fieldIndex, int[] values, java.lang.String text, java.util.Locale locale)
DateTimeField
If setting this field would make other fields invalid, then those fields may be changed. For example if the current date is the 31st January, and the month is set to February, the day would be invalid. Instead, the day would be changed to the closest value - the 28th/29th February as appropriate.
set
in class DateTimeField
instant
- the partial instantfieldIndex
- the index of this field in the instantvalues
- the values of the partial instant which should be updatedtext
- the text value to setlocale
- the locale to use for selecting a text symbol, null for defaultpublic DurationField getDurationField()
DateTimeField
getDurationField
in class DateTimeField
public DurationField getRangeDurationField()
DateTimeField
getRangeDurationField
in class DateTimeField
public boolean isLeap(long instant)
DateTimeField
For example, a leap year would return true, a non leap year would return false.
isLeap
in class DateTimeField
instant
- the instant to check for leap statuspublic int getLeapAmount(long instant)
DateTimeField
For example, a leap year would return one, a non leap year would return zero.
getLeapAmount
in class DateTimeField
instant
- the instant to check for leap statuspublic DurationField getLeapDurationField()
DateTimeField
getLeapDurationField
in class DateTimeField
public int getMinimumValue()
DateTimeField
getMinimumValue
in class DateTimeField
public int getMinimumValue(long instant)
DateTimeField
getMinimumValue
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to querypublic int getMinimumValue(ReadablePartial instant)
DateTimeField
getMinimumValue
in class DateTimeField
instant
- the partial instant to querypublic int getMinimumValue(ReadablePartial instant, int[] values)
DateTimeField
getMinimumValue
in class DateTimeField
instant
- the partial instant to queryvalues
- the values to usepublic int getMaximumValue()
DateTimeField
getMaximumValue
in class DateTimeField
public int getMaximumValue(long instant)
DateTimeField
getMaximumValue
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to querypublic int getMaximumValue(ReadablePartial instant)
DateTimeField
getMaximumValue
in class DateTimeField
instant
- the partial instant to querypublic int getMaximumValue(ReadablePartial instant, int[] values)
DateTimeField
getMaximumValue
in class DateTimeField
instant
- the partial instant to queryvalues
- the values to usepublic int getMaximumTextLength(java.util.Locale locale)
DateTimeField
getMaximumTextLength
in class DateTimeField
locale
- the locale to use for selecting a text symbolpublic int getMaximumShortTextLength(java.util.Locale locale)
DateTimeField
getMaximumShortTextLength
in class DateTimeField
locale
- the locale to use for selecting a text symbolpublic long roundFloor(long instant)
DateTimeField
For example, a datetime of 2002-11-02T23:34:56.789, rounded to the lowest whole hour is 2002-11-02T23:00:00.000.
roundFloor
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to roundpublic long roundCeiling(long instant)
DateTimeField
For example, a datetime of 2002-11-02T23:34:56.789, rounded to the highest whole hour is 2002-11-03T00:00:00.000.
roundCeiling
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to roundpublic long roundHalfFloor(long instant)
DateTimeField
roundHalfFloor
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to roundpublic long roundHalfCeiling(long instant)
DateTimeField
roundHalfCeiling
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to roundpublic long roundHalfEven(long instant)
DateTimeField
If the millisecond value is exactly halfway between the floor and ceiling, the ceiling is chosen over the floor only if it makes this field's value even.
roundHalfEven
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to roundpublic long remainder(long instant)
DateTimeField
For example, on a datetime of 2002-11-02T23:34:56.789, the remainder by hour is 34 minutes and 56.789 seconds.
remainder
in class DateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to get the
remainderpublic java.lang.String toString()
DateTimeField
toString
in class DateTimeField
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"