|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.joda.time.DateTimeField org.joda.time.field.BaseDateTimeField org.joda.time.field.DecoratedDateTimeField org.joda.time.field.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.
DividedDateTimeField
Constructor Summary | |
---|---|
RemainderDateTimeField(DateTimeField field,
DateTimeFieldType type,
int divisor)
Constructor. |
|
RemainderDateTimeField(DateTimeField field,
DurationField rangeField,
DateTimeFieldType type,
int divisor)
Constructor. |
|
RemainderDateTimeField(DividedDateTimeField dividedField)
Construct a RemainderDateTimeField that compliments the given DividedDateTimeField. |
|
RemainderDateTimeField(DividedDateTimeField dividedField,
DateTimeFieldType type)
Construct a RemainderDateTimeField that compliments the given DividedDateTimeField. |
|
RemainderDateTimeField(DividedDateTimeField dividedField,
DurationField durationField,
DateTimeFieldType type)
Construct a RemainderDateTimeField that compliments the given DividedDateTimeField. |
Method Summary | |
---|---|
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. |
DurationField |
getDurationField()
Returns the duration per unit value of this field. |
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. |
Methods inherited from class org.joda.time.field.DecoratedDateTimeField |
---|
getWrappedField, isLenient |
Methods inherited from class org.joda.time.field.BaseDateTimeField |
---|
add, 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, set, set, set, set, toString |
Methods inherited from class org.joda.time.DateTimeField |
---|
setExtended |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public RemainderDateTimeField(DateTimeField field, DateTimeFieldType type, int divisor)
field
- the field to wrap, like "year()".type
- the field type this field actually usesdivisor
- divisor, such as 100 years in a century
IllegalArgumentException
- if divisor is less than twopublic RemainderDateTimeField(DateTimeField field, DurationField rangeField, DateTimeFieldType type, int divisor)
field
- the field to wrap, like "year()".rangeField
- the range fieldtype
- the field type this field actually usesdivisor
- divisor, such as 100 years in a century
IllegalArgumentException
- if divisor is less than twopublic RemainderDateTimeField(DividedDateTimeField dividedField)
dividedField
- complimentary divided field, like "century()".public RemainderDateTimeField(DividedDateTimeField dividedField, DateTimeFieldType type)
dividedField
- complimentary divided field, like "century()".type
- the field type this field actually usespublic RemainderDateTimeField(DividedDateTimeField dividedField, DurationField durationField, DateTimeFieldType type)
dividedField
- complimentary divided field, like "century()".durationField
- the duration fieldtype
- the field type this field actually usesMethod Detail |
---|
public int get(long instant)
get
in class DecoratedDateTimeField
instant
- the time instant in millis to query.
public long addWrapField(long instant, int amount)
addWrapField
in class BaseDateTimeField
instant
- the time instant in millis to update.amount
- the amount to add (can be negative).
public long set(long instant, int value)
set
in class DecoratedDateTimeField
instant
- the time instant in millis to update.value
- value of remainder units to set.
IllegalArgumentException
- if value is too large or too small.public DurationField getDurationField()
BaseDateTimeField
getDurationField
in class DecoratedDateTimeField
public DurationField getRangeDurationField()
getRangeDurationField
in class DecoratedDateTimeField
public int getMinimumValue()
getMinimumValue
in class DecoratedDateTimeField
public int getMaximumValue()
getMaximumValue
in class DecoratedDateTimeField
public long roundFloor(long instant)
BaseDateTimeField
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 class DecoratedDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to round
public long roundCeiling(long instant)
BaseDateTimeField
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 class BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to round
public long roundHalfFloor(long instant)
BaseDateTimeField
roundHalfFloor
in class BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to round
public long roundHalfCeiling(long instant)
BaseDateTimeField
roundHalfCeiling
in class BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to round
public long roundHalfEven(long instant)
BaseDateTimeField
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 class BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to round
public long remainder(long instant)
BaseDateTimeField
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 class BaseDateTimeField
instant
- the milliseconds from 1970-01-01T00:00:00Z to get the
remainder
public int getDivisor()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |