static final class ZonedChronology.ZonedDateTimeField extends BaseDateTimeField
This class converts passed in instants to local wall time, and vice versa on output.
| Modifier and Type | Field and Description |
|---|---|
(package private) DurationField |
iDurationField |
(package private) DateTimeField |
iField |
(package private) DurationField |
iLeapDurationField |
(package private) DurationField |
iRangeDurationField |
(package private) boolean |
iTimeField |
(package private) DateTimeZone |
iZone |
private static long |
serialVersionUID |
| Constructor and Description |
|---|
ZonedDateTimeField(DateTimeField field,
DateTimeZone zone,
DurationField durationField,
DurationField rangeDurationField,
DurationField leapDurationField) |
| Modifier and Type | Method and Description |
|---|---|
long |
add(long instant,
int value)
Adds a value (which may be negative) to the instant value,
overflowing into larger fields if necessary.
|
long |
add(long instant,
long value)
Adds a value (which may be negative) to the instant value,
overflowing into larger fields if necessary.
|
long |
addWrapField(long instant,
int value)
Adds a value (which may be negative) to the instant value,
wrapping within this field.
|
boolean |
equals(java.lang.Object obj) |
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,
java.util.Locale locale)
Get the human-readable, short text value of this field from the milliseconds.
|
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,
java.util.Locale locale)
Get the human-readable, text value of this field from the milliseconds.
|
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 instant.
|
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 instant.
|
int |
getMinimumValue(ReadablePartial instant,
int[] values)
Get the minimum value for this field using the partial instant and
the specified values.
|
private int |
getOffsetToAdd(long instant) |
DurationField |
getRangeDurationField()
Returns the range duration of this field.
|
int |
hashCode() |
boolean |
isLeap(long instant)
Returns whether this field is 'leap' for the specified instant.
|
boolean |
isLenient()
Returns true if the set method is lenient.
|
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 |
set(long instant,
int value)
Sets a value in the milliseconds supplied.
|
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.
|
add, addWrapField, addWrapPartial, convertText, getAsShortText, getAsShortText, getAsShortText, getAsText, getAsText, getAsText, getName, getType, isSupported, roundHalfCeiling, roundHalfEven, roundHalfFloor, set, set, set, toStringsetExtendedprivate static final long serialVersionUID
final DateTimeField iField
final DateTimeZone iZone
final DurationField iDurationField
final boolean iTimeField
final DurationField iRangeDurationField
final DurationField iLeapDurationField
ZonedDateTimeField(DateTimeField field, DateTimeZone zone, DurationField durationField, DurationField rangeDurationField, DurationField leapDurationField)
public boolean isLenient()
DateTimeFieldisLenient in class DateTimeFieldpublic int get(long instant)
BaseDateTimeFieldget in class BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to querypublic java.lang.String getAsText(long instant,
java.util.Locale locale)
BaseDateTimeFieldThe default implementation returns getAsText(get(instant), locale).
getAsText in class BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to querylocale - the locale to use for selecting a text symbol, null means defaultpublic java.lang.String getAsShortText(long instant,
java.util.Locale locale)
BaseDateTimeFieldThe default implementation returns getAsShortText(get(instant), locale).
getAsShortText in class BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to querylocale - the locale to use for selecting a text symbol, null means defaultpublic java.lang.String getAsText(int fieldValue,
java.util.Locale locale)
BaseDateTimeFieldThe default implementation returns Integer.toString(get(instant)).
Note: subclasses that override this method should also override getMaximumTextLength.
getAsText in class BaseDateTimeFieldfieldValue - the numeric value to convert to textlocale - the locale to use for selecting a text symbol, null for defaultpublic java.lang.String getAsShortText(int fieldValue,
java.util.Locale locale)
BaseDateTimeFieldThe default implementation returns getAsText(fieldValue, locale).
Note: subclasses that override this method should also override getMaximumShortTextLength.
getAsShortText in class BaseDateTimeFieldfieldValue - 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)
BaseDateTimeFieldThe 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 BaseDateTimeFieldinstant - 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)
BaseDateTimeFieldadd in class BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to add tovalue - the long value to add, in the units of the fieldBaseDateTimeField.add(long,int)public long addWrapField(long instant,
int value)
BaseDateTimeFieldThe 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.
addWrapField in class BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to add tovalue - the value to add, in the units of the fieldpublic long set(long instant,
int value)
BaseDateTimeFieldThe 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 BaseDateTimeFieldinstant - 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)
BaseDateTimeField
This implementation uses convertText(String, Locale) and
BaseDateTimeField.set(long, int).
Note: subclasses that override this method should also override getAsText.
set in class BaseDateTimeFieldinstant - 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 int getDifference(long minuendInstant,
long subtrahendInstant)
BaseDateTimeFieldlong instant = ... int v = ... int age = getDifference(add(instant, v), instant);The value 'age' is the same as the value 'v'.
getDifference in class BaseDateTimeFieldminuendInstant - 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)
BaseDateTimeFieldlong instant = ... long v = ... long age = getDifferenceAsLong(add(instant, v), instant);The value 'age' is the same as the value 'v'.
getDifferenceAsLong in class BaseDateTimeFieldminuendInstant - the milliseconds from 1970-01-01T00:00:00Z to
subtract fromsubtrahendInstant - the milliseconds from 1970-01-01T00:00:00Z to
subtract off the minuendpublic final DurationField getDurationField()
BaseDateTimeFieldgetDurationField in class BaseDateTimeFieldpublic final DurationField getRangeDurationField()
BaseDateTimeFieldgetRangeDurationField in class BaseDateTimeFieldpublic boolean isLeap(long instant)
BaseDateTimeFieldFor example, a leap year would return true, a non leap year would return false.
This implementation returns false.
isLeap in class BaseDateTimeFieldinstant - the instant to check for leap statuspublic int getLeapAmount(long instant)
BaseDateTimeFieldFor example, a leap year would return one, a non leap year would return zero.
This implementation returns zero.
getLeapAmount in class BaseDateTimeFieldinstant - the instant to check for leap statuspublic final DurationField getLeapDurationField()
BaseDateTimeFieldThis implementation returns null.
getLeapDurationField in class BaseDateTimeFieldpublic long roundFloor(long instant)
BaseDateTimeFieldFor 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 BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to roundpublic long roundCeiling(long instant)
BaseDateTimeFieldFor 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.
roundCeiling in class BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to roundpublic long remainder(long instant)
BaseDateTimeFieldFor 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.
remainder in class BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to get the
remainderpublic int getMinimumValue()
BaseDateTimeFieldgetMinimumValue in class BaseDateTimeFieldpublic int getMinimumValue(long instant)
BaseDateTimeField
This implementation returns the same as BaseDateTimeField.getMinimumValue().
getMinimumValue in class BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to querypublic int getMinimumValue(ReadablePartial instant)
BaseDateTimeField
This implementation returns the same as BaseDateTimeField.getMinimumValue().
getMinimumValue in class BaseDateTimeFieldinstant - the partial instant to querypublic int getMinimumValue(ReadablePartial instant, int[] values)
BaseDateTimeField
This implementation returns the same as BaseDateTimeField.getMinimumValue(ReadablePartial).
getMinimumValue in class BaseDateTimeFieldinstant - the partial instant to queryvalues - the values to usepublic int getMaximumValue()
BaseDateTimeFieldgetMaximumValue in class BaseDateTimeFieldpublic int getMaximumValue(long instant)
BaseDateTimeField
This implementation returns the same as BaseDateTimeField.getMaximumValue().
getMaximumValue in class BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to querypublic int getMaximumValue(ReadablePartial instant)
BaseDateTimeField
This implementation returns the same as BaseDateTimeField.getMaximumValue().
getMaximumValue in class BaseDateTimeFieldinstant - the partial instant to querypublic int getMaximumValue(ReadablePartial instant, int[] values)
BaseDateTimeField
This implementation returns the same as BaseDateTimeField.getMaximumValue(ReadablePartial).
getMaximumValue in class BaseDateTimeFieldinstant - the partial instant to queryvalues - the values to usepublic int getMaximumTextLength(java.util.Locale locale)
BaseDateTimeFieldgetMaximumTextLength in class BaseDateTimeFieldlocale - the locale to use for selecting a text symbolpublic int getMaximumShortTextLength(java.util.Locale locale)
BaseDateTimeFieldgetMaximumShortTextLength in class BaseDateTimeFieldlocale - the locale to use for selecting a text symbolprivate int getOffsetToAdd(long instant)
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object