org.joda.time.field
Class RemainderDateTimeField
public class RemainderDateTimeField
Counterpart remainder datetime field to
DividedDateTimeField
. The
field's unit duration is unchanged, but the range duration is scaled
accordingly.
RemainderDateTimeField is thread-safe and immutable.
long | addWrapField(long instant, int amount) - Add the specified amount to the specified time instant, wrapping around
within the remainder range if necessary.
|
int | get(long instant) - Get the remainder from the specified time instant.
|
int | getDivisor() - Returns the divisor applied, in the field's units.
|
int | getMaximumValue() - Get the maximum value for the field, which is always one less than the
divisor.
|
int | getMinimumValue() - Get the minimum value for the field, which is always zero.
|
DurationField | getRangeDurationField() - Returns a scaled version of the wrapped field's unit duration field.
|
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) - Set the specified amount of remainder units to the specified time instant.
|
add , add , add , addWrapField , addWrapField , addWrapPartial , convertText , get , getAsShortText , getAsShortText , getAsShortText , getAsShortText , getAsShortText , getAsText , getAsText , getAsText , getAsText , getAsText , getDifference , getDifferenceAsLong , getDurationField , getLeapAmount , getLeapDurationField , getMaximumShortTextLength , getMaximumTextLength , getMaximumValue , getMaximumValue , getMaximumValue , getMaximumValue , getMinimumValue , getMinimumValue , getMinimumValue , getMinimumValue , getName , getRangeDurationField , getType , isLeap , isSupported , remainder , roundCeiling , roundFloor , roundHalfCeiling , roundHalfEven , roundHalfFloor , set , set , set , set , set , toString |
add , add , add , addWrapField , addWrapField , addWrapPartial , get , getAsShortText , getAsShortText , getAsShortText , getAsShortText , getAsShortText , getAsText , getAsText , getAsText , getAsText , getAsText , getDifference , getDifferenceAsLong , getDurationField , getLeapAmount , getLeapDurationField , getMaximumShortTextLength , getMaximumTextLength , getMaximumValue , getMaximumValue , getMaximumValue , getMaximumValue , getMinimumValue , getMinimumValue , getMinimumValue , getMinimumValue , getName , getRangeDurationField , getType , isLeap , isLenient , isSupported , remainder , roundCeiling , roundFloor , roundHalfCeiling , roundHalfEven , roundHalfFloor , set , set , set , set , set , toString |
RemainderDateTimeField
public RemainderDateTimeField(DateTimeField field,
DateTimeFieldType type,
int divisor)
Constructor.
field
- the field to wrap, like "year()".type
- the field type this field actually usesdivisor
- divisor, such as 100 years in a century
RemainderDateTimeField
public RemainderDateTimeField(DividedDateTimeField dividedField)
Construct a RemainderDateTimeField that compliments the given
DividedDateTimeField.
dividedField
- complimentary divided field, like "century()".
RemainderDateTimeField
public RemainderDateTimeField(DividedDateTimeField dividedField,
DateTimeFieldType type)
Construct a RemainderDateTimeField that compliments the given
DividedDateTimeField.
dividedField
- complimentary divided field, like "century()".type
- the field type this field actually uses
addWrapField
public long addWrapField(long instant,
int amount)
Add the specified amount to the specified time instant, wrapping around
within the remainder range if necessary. The amount added may be
negative.
- addWrapField in interface BaseDateTimeField
instant
- the time instant in millis to update.amount
- the amount to add (can be negative).
- the updated time instant.
get
public int get(long instant)
Get the remainder from the specified time instant.
- get in interface DecoratedDateTimeField
instant
- the time instant in millis to query.
- the remainder extracted from the input.
getDivisor
public int getDivisor()
Returns the divisor applied, in the field's units.
remainder
public long remainder(long instant)
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.
- remainder in interface BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to get the
remainder
- remainder duration, in milliseconds
roundCeiling
public long roundCeiling(long instant)
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.
- roundCeiling in interface BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to round
roundFloor
public long roundFloor(long instant)
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.
- roundFloor in interface DecoratedDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to round
roundHalfCeiling
public long roundHalfCeiling(long instant)
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.
- roundHalfCeiling in interface BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to round
roundHalfEven
public long roundHalfEven(long instant)
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.
- roundHalfEven in interface BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to round
roundHalfFloor
public long roundHalfFloor(long instant)
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.
- roundHalfFloor in interface BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to round
set
public long set(long instant,
int value)
Set the specified amount of remainder units to the specified time instant.
- set in interface DecoratedDateTimeField
instant
- the time instant in millis to update.value
- value of remainder units to set.
- the updated time instant.
Copyright (c) 2001-2006 - Joda.org