java.lang.Object | ||||
↳ | org.joda.time.DateTimeField | |||
↳ | org.joda.time.field.BaseDateTimeField | |||
↳ | org.joda.time.field.DecoratedDateTimeField | |||
↳ | org.joda.time.field.DividedDateTimeField |
Divides a DateTimeField such that the retrieved values are reduced by a fixed divisor. The field's unit duration is scaled accordingly, but the range duration is unchanged.
DividedDateTimeField is thread-safe and immutable.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor.
| |||||||||||
Construct a DividedDateTimeField that compliments the given
RemainderDateTimeField.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add the specified amount of scaled units to the specified time
instant.
| |||||||||||
Add the specified amount of scaled units to the specified time
instant.
| |||||||||||
Add to the scaled component of the specified time instant,
wrapping around within that component if necessary.
| |||||||||||
Get the amount of scaled units from the specified time instant.
| |||||||||||
Computes the difference between two instants, as measured in the units
of this field.
| |||||||||||
Computes the difference between two instants, as measured in the units
of this field.
| |||||||||||
Returns the divisor applied, in the field's units.
| |||||||||||
Returns a scaled version of the wrapped field's unit duration field.
| |||||||||||
Get the maximum value for the field.
| |||||||||||
Get the minimum value for the field.
| |||||||||||
Returns the fractional duration milliseconds of this field.
| |||||||||||
Round to the lowest whole unit of this field.
| |||||||||||
Set the specified amount of scaled units to the specified time instant.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.joda.time.field.DecoratedDateTimeField
| |||||||||||
From class
org.joda.time.field.BaseDateTimeField
| |||||||||||
From class
org.joda.time.DateTimeField
| |||||||||||
From class
java.lang.Object
|
Constructor.
field | the field to wrap, like "year()". |
---|---|
type | the field type this field will actually use |
divisor | divisor, such as 100 years in a century |
IllegalArgumentException | if divisor is less than two |
---|
Construct a DividedDateTimeField that compliments the given RemainderDateTimeField.
remainderField | complimentary remainder field, like "yearOfCentury()". |
---|---|
type | the field type this field will actually use |
Add the specified amount of scaled units to the specified time instant. The amount added may be negative.
instant | the time instant in millis to update. |
---|---|
amount | the amount of scaled units to add (can be negative). |
Add the specified amount of scaled units to the specified time instant. The amount added may be negative.
instant | the time instant in millis to update. |
---|---|
amount | the amount of scaled units to add (can be negative). |
Add to the scaled component of the specified time instant, wrapping around within that component if necessary.
instant | the time instant in millis to update. |
---|---|
amount | the amount of scaled units to add (can be negative). |
Get the amount of scaled units from the specified time instant.
instant | the time instant in millis to query. |
---|
Computes the difference between two instants, as measured in the units of this field. Any fractional units are dropped from the result. Calling getDifference reverses the effect of calling add. In the following code:
long instant = ... int v = ... int age = getDifference(add(instant, v), instant);The value 'age' is the same as the value 'v'.
minuendInstant | the milliseconds from 1970-01-01T00:00:00Z to subtract from |
---|---|
subtrahendInstant | the milliseconds from 1970-01-01T00:00:00Z to subtract off the minuend |
Computes the difference between two instants, as measured in the units of this field. Any fractional units are dropped from the result. Calling getDifference reverses the effect of calling add. In the following code:
long instant = ... long v = ... long age = getDifferenceAsLong(add(instant, v), instant);The value 'age' is the same as the value 'v'.
minuendInstant | the milliseconds from 1970-01-01T00:00:00Z to subtract from |
---|---|
subtrahendInstant | the milliseconds from 1970-01-01T00:00:00Z to subtract off the minuend |
Returns the divisor applied, in the field's units.
Returns a scaled version of the wrapped field's unit duration field.
Get the maximum value for the field.
Get the minimum value for the field.
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.
instant | the milliseconds from 1970-01-01T00:00:00Z to get the remainder |
---|
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.
instant | the milliseconds from 1970-01-01T00:00:00Z to round |
---|
Set the specified amount of scaled units to the specified time instant.
instant | the time instant in millis to update. |
---|---|
value | value of scaled units to set. |
IllegalArgumentException | if value is too large or too small. |
---|