public class DividedDateTimeField extends DecoratedDateTimeField
DividedDateTimeField is thread-safe and immutable.
RemainderDateTimeField| Constructor and Description |
|---|
DividedDateTimeField(DateTimeField field,
DateTimeFieldType type,
int divisor)
Constructor.
|
DividedDateTimeField(DateTimeField field,
DurationField rangeField,
DateTimeFieldType type,
int divisor)
Constructor.
|
DividedDateTimeField(RemainderDateTimeField remainderField,
DateTimeFieldType type)
Construct a DividedDateTimeField that compliments the given
RemainderDateTimeField.
|
DividedDateTimeField(RemainderDateTimeField remainderField,
DurationField rangeField,
DateTimeFieldType type)
Construct a DividedDateTimeField that compliments the given
RemainderDateTimeField.
|
| Modifier and Type | Method and Description |
|---|---|
long |
add(long instant,
int amount)
Add the specified amount of scaled units to the specified time
instant.
|
long |
add(long instant,
long amount)
Add the specified amount of scaled units to the specified time
instant.
|
long |
addWrapField(long instant,
int amount)
Add to the scaled component of the specified time instant,
wrapping around within that component if necessary.
|
int |
get(long instant)
Get the amount of scaled units from the specified time 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.
|
int |
getDivisor()
Returns the divisor applied, in the field's units.
|
DurationField |
getDurationField()
Returns a scaled version of the wrapped field's unit duration field.
|
int |
getMaximumValue()
Get the maximum value for the field.
|
int |
getMinimumValue()
Get the minimum value for the field.
|
DurationField |
getRangeDurationField()
Returns the range duration of this field.
|
long |
remainder(long instant)
Returns the fractional duration milliseconds of this field.
|
long |
roundFloor(long instant)
Round to the lowest whole unit of this field.
|
long |
set(long instant,
int value)
Set the specified amount of scaled units to the specified time instant.
|
getWrappedField, isLenientadd, addWrapField, addWrapPartial, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsText, getAsText, getAsText, getAsText, getAsText, getLeapAmount, getLeapDurationField, getMaximumShortTextLength, getMaximumTextLength, getMaximumValue, getMaximumValue, getMaximumValue, getMinimumValue, getMinimumValue, getMinimumValue, getName, getType, isLeap, isSupported, roundCeiling, roundHalfCeiling, roundHalfEven, roundHalfFloor, set, set, set, set, toStringsetExtendedpublic DividedDateTimeField(DateTimeField field, DateTimeFieldType type, int divisor)
field - the field to wrap, like "year()".type - the field type this field will actually usedivisor - divisor, such as 100 years in a centuryjava.lang.IllegalArgumentException - if divisor is less than twopublic DividedDateTimeField(DateTimeField field, DurationField rangeField, DateTimeFieldType type, int divisor)
field - the field to wrap, like "year()".rangeField - the range field, null to derivetype - the field type this field will actually usedivisor - divisor, such as 100 years in a centuryjava.lang.IllegalArgumentException - if divisor is less than twopublic DividedDateTimeField(RemainderDateTimeField remainderField, DateTimeFieldType type)
remainderField - complimentary remainder field, like "yearOfCentury()".type - the field type this field will actually usepublic DividedDateTimeField(RemainderDateTimeField remainderField, DurationField rangeField, DateTimeFieldType type)
remainderField - complimentary remainder field, like "yearOfCentury()".rangeField - the range field, null to derivetype - the field type this field will actually usepublic DurationField getRangeDurationField()
BaseDateTimeFieldgetRangeDurationField in class DecoratedDateTimeFieldpublic int get(long instant)
get in class DecoratedDateTimeFieldinstant - the time instant in millis to query.public long add(long instant,
int amount)
add in class BaseDateTimeFieldinstant - the time instant in millis to update.amount - the amount of scaled units to add (can be negative).public long add(long instant,
long amount)
add in class BaseDateTimeFieldinstant - the time instant in millis to update.amount - the amount of scaled units to add (can be negative).BaseDateTimeField.add(long,int)public long addWrapField(long instant,
int amount)
addWrapField in class BaseDateTimeFieldinstant - the time instant in millis to update.amount - the amount of scaled units to add (can be negative).public 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 long set(long instant,
int value)
set in class DecoratedDateTimeFieldinstant - the time instant in millis to update.value - value of scaled units to set.java.lang.IllegalArgumentException - if value is too large or too small.public DurationField getDurationField()
getDurationField in class DecoratedDateTimeFieldpublic int getMinimumValue()
getMinimumValue in class DecoratedDateTimeFieldpublic int getMaximumValue()
getMaximumValue in class DecoratedDateTimeFieldpublic 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 DecoratedDateTimeFieldinstant - 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 getDivisor()
Copyright © 2010 - 2023 Adobe. All Rights Reserved