public class PreciseDateTimeField extends PreciseDurationDateTimeField
This DateTimeField is useful for defining DateTimeFields that are composed
of precise durations, like time of day fields. If either duration field is
imprecise, then an ImpreciseDateTimeField may be used instead.
PreciseDateTimeField is thread-safe and immutable.
ImpreciseDateTimeField| Modifier and Type | Field and Description |
|---|---|
private int |
iRange
The maximum range in the correct units
|
private DurationField |
iRangeField |
private static long |
serialVersionUID |
iUnitMillis| Constructor and Description |
|---|
PreciseDateTimeField(DateTimeFieldType type,
DurationField unit,
DurationField range)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
long |
addWrapField(long instant,
int amount)
Add to the component of the specified time instant, wrapping around
within that component if necessary.
|
int |
get(long instant)
Get the amount of fractional units from the specified time instant.
|
int |
getMaximumValue()
Get the maximum value for the field.
|
int |
getRange()
Returns the range of the field in the field's units.
|
DurationField |
getRangeDurationField()
Returns the range duration of this field.
|
long |
set(long instant,
int value)
Set the specified amount of units to the specified time instant.
|
getDurationField, getMaximumValueForSet, getMinimumValue, getUnitMillis, isLenient, remainder, roundCeiling, roundFlooradd, add, add, addWrapField, addWrapPartial, convertText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsText, getAsText, getAsText, getAsText, getAsText, getDifference, getDifferenceAsLong, getLeapAmount, getLeapDurationField, getMaximumShortTextLength, getMaximumTextLength, getMaximumValue, getMaximumValue, getMaximumValue, getMinimumValue, getMinimumValue, getMinimumValue, getName, getType, isLeap, isSupported, roundHalfCeiling, roundHalfEven, roundHalfFloor, set, set, set, set, toStringsetExtendedprivate static final long serialVersionUID
private final int iRange
private final DurationField iRangeField
public PreciseDateTimeField(DateTimeFieldType type, DurationField unit, DurationField range)
type - the field type this field usesunit - precise unit duration, like "seconds()".range - precise range duration, preferably a multiple of the unit,
like "minutes()".java.lang.IllegalArgumentException - if either duration field is imprecisejava.lang.IllegalArgumentException - if unit milliseconds is less than one
or effective value range is less than two.public int get(long instant)
get in class BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to querypublic long addWrapField(long instant,
int amount)
addWrapField in class BaseDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to add toamount - the amount of units to add (can be negative).public long set(long instant,
int value)
set in class PreciseDurationDateTimeFieldinstant - the milliseconds from 1970-01-01T00:00:00Z to set invalue - value of units to set.java.lang.IllegalArgumentException - if value is too large or too small.public DurationField getRangeDurationField()
getRangeDurationField in class BaseDateTimeFieldpublic int getMaximumValue()
getMaximumValue in class BaseDateTimeFieldpublic int getRange()
For example, 60 for seconds per minute. The field is allowed values from 0 to range - 1.