java.lang.Object | ||
↳ | org.joda.time.DateTimeField | |
↳ | org.joda.time.field.BaseDateTimeField |
Known Direct Subclasses |
Known Indirect Subclasses |
BaseDateTimeField provides the common behaviour for DateTimeField implementations.
This class should generally not be used directly by API users. The DateTimeField class should be used when different kinds of DateTimeField objects are to be referenced.
BaseDateTimeField is thread-safe and immutable, and its subclasses must be as well.
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds a value (which may be negative) to the partial instant,
throwing an exception if the maximum size of the instant is reached.
| |||||||||||
Adds a value (which may be negative) to the instant value,
overflowing into larger fields if necessary.
| |||||||||||
Adds a value (which may be negative) to the instant value,
overflowing into larger fields if necessary.
| |||||||||||
Adds a value (which may be negative) to the instant value,
wrapping within this field.
| |||||||||||
Adds a value (which may be negative) to the partial instant,
wrapping within this field.
| |||||||||||
Adds a value (which may be negative) to the partial instant,
wrapping the whole partial if the maximum size of the partial is reached.
| |||||||||||
Get the value of this field from the milliseconds.
| |||||||||||
Get the human-readable, short text value of this field from a partial instant.
| |||||||||||
Get the human-readable, short text value of this field from the field value.
| |||||||||||
Get the human-readable, short text value of this field from a partial instant.
| |||||||||||
Get the human-readable, short text value of this field from the milliseconds.
| |||||||||||
Get the human-readable, short text value of this field from the milliseconds.
| |||||||||||
Get the human-readable, text value of this field from a partial instant.
| |||||||||||
Get the human-readable, text value of this field from the field value.
| |||||||||||
Get the human-readable, text value of this field from the milliseconds.
| |||||||||||
Get the human-readable, text value of this field from the milliseconds.
| |||||||||||
Get the human-readable, text value of this field from a partial instant.
| |||||||||||
Computes the difference between two instants, as measured in the units
of this field.
| |||||||||||
Computes the difference between two instants, as measured in the units
of this field.
| |||||||||||
Returns the duration per unit value of this field.
| |||||||||||
Gets the amount by which this field is 'leap' for the specified instant.
| |||||||||||
If this field were to leap, then it would be in units described by the
returned duration.
| |||||||||||
Get the maximum short text value for this field.
| |||||||||||
Get the maximum text value for this field.
| |||||||||||
Get the maximum value for this field evaluated at the specified time.
| |||||||||||
Get the maximum value for this field evaluated at the specified instant.
| |||||||||||
Get the maximum allowable value for this field.
| |||||||||||
Get the maximum value for this field using the partial instant and
the specified values.
| |||||||||||
Get the minimum value for this field evaluated at the specified instant.
| |||||||||||
Get the minimum value for this field using the partial instant and
the specified values.
| |||||||||||
Get the minimum value for this field evaluated at the specified time.
| |||||||||||
Get the minimum allowable value for this field.
| |||||||||||
Get the name of the field.
| |||||||||||
Returns the range duration of this field.
| |||||||||||
Get the type of the field.
| |||||||||||
Returns whether this field is 'leap' for the specified instant.
| |||||||||||
Returns true if this field is supported.
| |||||||||||
Returns the fractional duration milliseconds of this field.
| |||||||||||
Round to the highest whole unit of this field.
| |||||||||||
Round to the lowest whole unit of this field.
| |||||||||||
Round to the nearest whole unit of this field.
| |||||||||||
Round to the nearest whole unit of this field.
| |||||||||||
Round to the nearest whole unit of this field.
| |||||||||||
Sets a value in the milliseconds supplied from a human-readable, text value.
| |||||||||||
Sets a value using the specified partial instant.
| |||||||||||
Sets a value in the milliseconds supplied from a human-readable, text value.
| |||||||||||
Sets a value in the milliseconds supplied.
| |||||||||||
Sets a value in the milliseconds supplied from a human-readable, text value.
| |||||||||||
Get a suitable debug string.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Convert the specified text and locale into a value.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.joda.time.DateTimeField
| |||||||||||
From class
java.lang.Object
|
Adds a value (which may be negative) to the partial instant, throwing an exception if the maximum size of the instant is reached.
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
instant | the partial instant |
---|---|
fieldIndex | the index of this field in the partial |
values | the values of the partial instant which should be updated |
valueToAdd | the value to add, in the units of the field |
IllegalArgumentException | if the value is invalid or the maximum instant is reached |
---|
Adds a value (which may be negative) to the instant value, overflowing into larger fields if necessary.
instant | the milliseconds from 1970-01-01T00:00:00Z to add to |
---|---|
value | the long value to add, in the units of the field |
IllegalArgumentException | if value is too large |
---|
Adds a value (which may be negative) to the instant value, overflowing into larger fields if necessary.
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
instant | the milliseconds from 1970-01-01T00:00:00Z to add to |
---|---|
value | the value to add, in the units of the field |
Adds a value (which may be negative) to the instant value, wrapping within this field.
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
The default implementation internally calls set. Subclasses are encouraged to provide a more efficient implementation.
instant | the milliseconds from 1970-01-01T00:00:00Z to add to |
---|---|
value | the value to add, in the units of the field |
Adds a value (which may be negative) to the partial instant, wrapping within this field.
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
The default implementation internally calls set. Subclasses are encouraged to provide a more efficient implementation.
instant | the partial instant |
---|---|
fieldIndex | the index of this field in the instant |
values | the values of the partial instant which should be updated |
valueToAdd | the value to add, in the units of the field |
IllegalArgumentException | if the value is invalid |
---|
Adds a value (which may be negative) to the partial instant, wrapping the whole partial if the maximum size of the partial is reached.
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
instant | the partial instant |
---|---|
fieldIndex | the index of this field in the partial |
values | the values of the partial instant which should be updated |
valueToAdd | the value to add, in the units of the field |
IllegalArgumentException | if the value is invalid or the maximum instant is reached |
---|
Get the value of this field from the milliseconds.
instant | the milliseconds from 1970-01-01T00:00:00Z to query |
---|
Get the human-readable, short text value of this field from a partial instant. If the specified locale is null, the default locale is used.
The default implementation returns getAsShortText(fieldValue, locale).
partial | the partial instant to query |
---|---|
fieldValue | the field value of this field, provided for performance |
locale | the locale to use for selecting a text symbol, null for default |
Get the human-readable, short text value of this field from the field value. If the specified locale is null, the default locale is used.
The default implementation returns getAsText(fieldValue, locale).
Note: subclasses that override this method should also override getMaximumShortTextLength.
fieldValue | the numeric value to convert to text |
---|---|
locale | the locale to use for selecting a text symbol, null for default |
Get the human-readable, short text value of this field from a partial instant. If the specified locale is null, the default locale is used.
The default implementation calls get(DateTimeFieldType)
and getAsText(ReadablePartial, int, Locale)
.
partial | the partial instant to query |
---|---|
locale | the locale to use for selecting a text symbol, null for default |
Get the human-readable, short text value of this field from the milliseconds.
The default implementation calls getAsShortText(long, Locale)
.
instant | the milliseconds from 1970-01-01T00:00:00Z to query |
---|
Get the human-readable, short text value of this field from the milliseconds. If the specified locale is null, the default locale is used.
The default implementation returns getAsShortText(get(instant), locale).
instant | the milliseconds from 1970-01-01T00:00:00Z to query |
---|---|
locale | the locale to use for selecting a text symbol, null means default |
Get the human-readable, text value of this field from a partial instant. If the specified locale is null, the default locale is used.
The default implementation calls get(DateTimeFieldType)
and getAsText(ReadablePartial, int, Locale)
.
partial | the partial instant to query |
---|---|
locale | the locale to use for selecting a text symbol, null for default |
Get the human-readable, text value of this field from the field value. If the specified locale is null, the default locale is used.
The default implementation returns Integer.toString(get(instant)).
Note: subclasses that override this method should also override getMaximumTextLength.
fieldValue | the numeric value to convert to text |
---|---|
locale | the locale to use for selecting a text symbol, null for default |
Get the human-readable, text value of this field from the milliseconds. If the specified locale is null, the default locale is used.
The default implementation returns getAsText(get(instant), locale).
instant | the milliseconds from 1970-01-01T00:00:00Z to query |
---|---|
locale | the locale to use for selecting a text symbol, null means default |
Get the human-readable, text value of this field from the milliseconds.
The default implementation calls getAsText(long, Locale)
.
instant | the milliseconds from 1970-01-01T00:00:00Z to query |
---|
Get the human-readable, text value of this field from a partial instant. If the specified locale is null, the default locale is used.
The default implementation returns getAsText(fieldValue, locale).
partial | the partial instant to query |
---|---|
fieldValue | the field value of this field, provided for performance |
locale | the locale to use for selecting a text symbol, null for default |
Computes the difference between two instants, as measured in the units of this field. Any fractional units are dropped from the result. Calling getDifference reverses the effect of calling add. In the following code:
long instant = ... int v = ... int age = getDifference(add(instant, v), instant);The value 'age' is the same as the value 'v'.
minuendInstant | the milliseconds from 1970-01-01T00:00:00Z to subtract from |
---|---|
subtrahendInstant | the milliseconds from 1970-01-01T00:00:00Z to subtract off the minuend |
Computes the difference between two instants, as measured in the units of this field. Any fractional units are dropped from the result. Calling getDifference reverses the effect of calling add. In the following code:
long instant = ... long v = ... long age = getDifferenceAsLong(add(instant, v), instant);The value 'age' is the same as the value 'v'.
minuendInstant | the milliseconds from 1970-01-01T00:00:00Z to subtract from |
---|---|
subtrahendInstant | the milliseconds from 1970-01-01T00:00:00Z to subtract off the minuend |
Returns the duration per unit value of this field. For example, if this field represents "hour of day", then the unit duration is an hour.
Gets the amount by which this field is 'leap' for the specified instant.
For example, a leap year would return one, a non leap year would return zero.
This implementation returns zero.
instant | the instant to check for leap status |
---|
If this field were to leap, then it would be in units described by the returned duration. If this field doesn't ever leap, null is returned.
This implementation returns null.
Get the maximum short text value for this field. The default implementation returns getMaximumTextLength().
locale | the locale to use for selecting a text symbol |
---|
Get the maximum text value for this field. The default implementation returns the equivalent of Integer.toString(getMaximumValue()).length().
locale | the locale to use for selecting a text symbol |
---|
Get the maximum value for this field evaluated at the specified time.
This implementation returns the same as getMaximumValue()
.
instant | the milliseconds from 1970-01-01T00:00:00Z to query |
---|
Get the maximum value for this field evaluated at the specified instant.
This implementation returns the same as getMaximumValue()
.
instant | the partial instant to query |
---|
Get the maximum allowable value for this field.
Get the maximum value for this field using the partial instant and the specified values.
This implementation returns the same as getMaximumValue(ReadablePartial)
.
instant | the partial instant to query |
---|---|
values | the values to use |
Get the minimum value for this field evaluated at the specified instant.
This implementation returns the same as getMinimumValue()
.
instant | the partial instant to query |
---|
Get the minimum value for this field using the partial instant and the specified values.
This implementation returns the same as getMinimumValue(ReadablePartial)
.
instant | the partial instant to query |
---|---|
values | the values to use |
Get the minimum value for this field evaluated at the specified time.
This implementation returns the same as getMinimumValue()
.
instant | the milliseconds from 1970-01-01T00:00:00Z to query |
---|
Get the minimum allowable value for this field.
Get the name of the field.
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.
Returns the range duration of this field. For example, if this field represents "hour of day", then the range duration is a day.
Returns whether this field is 'leap' for the specified instant.
For example, a leap year would return true, a non leap year would return false.
This implementation returns false.
instant | the instant to check for leap status |
---|
Returns true if this field is supported.
Returns the fractional duration milliseconds of this field. In other words, calling remainder returns the duration that roundFloor would subtract.
For example, on a datetime of 2002-11-02T23:34:56.789, the remainder by hour is 34 minutes and 56.789 seconds.
The default implementation computes
instant - roundFloor(instant)
. Subclasses are encouraged to
provide a more efficient implementation.
instant | the milliseconds from 1970-01-01T00:00:00Z to get the remainder |
---|
Round to the highest whole unit of this field. The value of this field and all fields of a higher magnitude may be incremented in order to achieve this result. The fractional millis that cannot be expressed in whole increments of this field are set to minimum.
For example, a datetime of 2002-11-02T23:34:56.789, rounded to the highest whole hour is 2002-11-03T00:00:00.000.
The default implementation calls roundFloor, and if the instant is modified as a result, adds one field unit. Subclasses are encouraged to provide a more efficient implementation.
instant | the milliseconds from 1970-01-01T00:00:00Z to round |
---|
Round to the lowest whole unit of this field. After rounding, the value of this field and all fields of a higher magnitude are retained. The fractional millis that cannot be expressed in whole increments of this field are set to minimum.
For example, a datetime of 2002-11-02T23:34:56.789, rounded to the lowest whole hour is 2002-11-02T23:00:00.000.
instant | the milliseconds from 1970-01-01T00:00:00Z to round |
---|
Round to the nearest whole unit of this field. If the given millisecond value is closer to the floor, this function behaves like roundFloor. If the millisecond value is closer to the ceiling or is exactly halfway, this function behaves like roundCeiling.
instant | the milliseconds from 1970-01-01T00:00:00Z to round |
---|
Round to the nearest whole unit of this field. If the given millisecond value is closer to the floor, this function behaves like roundFloor. If the millisecond value is closer to the ceiling, this function behaves like roundCeiling.
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.
instant | the milliseconds from 1970-01-01T00:00:00Z to round |
---|
Round to the nearest whole unit of this field. If the given millisecond value is closer to the floor or is exactly halfway, this function behaves like roundFloor. If the millisecond value is closer to the ceiling, this function behaves like roundCeiling.
instant | the milliseconds from 1970-01-01T00:00:00Z to round |
---|
Sets a value in the milliseconds supplied from a human-readable, text value. If the specified locale is null, the default locale is used.
This implementation uses convertText(String, Locale)
and
set(long, int)
.
Note: subclasses that override this method should also override getAsText.
instant | the milliseconds from 1970-01-01T00:00:00Z to set in |
---|---|
text | the text value to set |
locale | the locale to use for selecting a text symbol, null for default |
IllegalArgumentException | if the text value is invalid |
---|
Sets a value using the specified partial instant.
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.
partial | the partial instant |
---|---|
fieldIndex | the index of this field in the instant |
values | the values to update |
newValue | the value to set, in the units of the field |
IllegalArgumentException | if the value is invalid |
---|
Sets a value in the milliseconds supplied from a human-readable, text value. If the specified locale is null, the default locale is used.
This implementation uses convertText(String, Locale)
and
set(ReadablePartial, int, int[], int)
.
instant | the partial instant |
---|---|
fieldIndex | the index of this field in the instant |
values | the values of the partial instant which should be updated |
text | the text value to set |
locale | the locale to use for selecting a text symbol, null for default |
IllegalArgumentException | if the text value is invalid |
---|
Sets a value in the milliseconds supplied.
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.
instant | the milliseconds from 1970-01-01T00:00:00Z to set in |
---|---|
value | the value to set, in the units of the field |
IllegalArgumentException | if the value is invalid |
---|
Sets a value in the milliseconds supplied from a human-readable, text value.
This implementation uses set(long, String, Locale)
.
Note: subclasses that override this method should also override getAsText.
instant | the milliseconds from 1970-01-01T00:00:00Z to set in |
---|---|
text | the text value to set |
IllegalArgumentException | if the text value is invalid |
---|
Convert the specified text and locale into a value.
text | the text to convert |
---|---|
locale | the locale to convert using |
IllegalArgumentException | if the text is invalid |
---|