|
Joda Time API | ||||||||||
| 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.chrono.DividedDateTimeField
Generic division datetime field.
RemainderDateTimeField,
Serialized Form| Constructor Summary | |
DividedDateTimeField(java.lang.String name,
DateTimeField field,
int unitDivisor)
Constructor |
|
| Method Summary | |
long |
add(long millis,
int amount)
Add the specified amount of divided units to the specified time instant. |
long |
add(long millis,
long amount)
Add the specified amount of divided units to the specified time instant. |
long |
addWrapped(long millis,
int amount)
Add to the divided component of the specified time instant, wrapping around within that component if necessary. |
int |
get(long millis)
Get the amount of divided units from the specified time instant. |
long |
getDifference(long minuendMillis,
long subtrahendMillis)
Computes the difference between two instants, as measured in the units of this field. |
DateTimeField |
getField()
Returns the DateTimeField being wrapped. |
int |
getMaximumValue()
Get the maximum value for the field. |
int |
getMinimumValue()
Get the minimum value for the field. |
long |
getRangeMillis()
Returns the wrapped field's range. |
int |
getUnitDivisor()
Returns the divisor to apply to the field in the field's units. |
long |
getUnitMillis()
Returns the wrapped field's unit size multiplied by the unit divisor. |
long |
remainder(long millis)
Retains only the fractional units of this field. |
long |
roundFloor(long millis)
Round to the lowest whole unit of this field. |
long |
set(long millis,
int value)
Set the specified amount of divided units to the specified time instant. |
| Methods inherited from class org.joda.time.DateTimeField |
addLong, getAsShortText, getAsShortText, getAsText, getAsText, getLeapAmount, getMaximumShortTextLength, getMaximumTextLength, getMaximumValue, getMinimumValue, getName, getWrappedValue, getWrappedValue, isLeap, roundCeiling, roundHalfCeiling, roundHalfEven, roundHalfFloor, set, set, toString, verifyValueBounds |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public DividedDateTimeField(java.lang.String name,
DateTimeField field,
int unitDivisor)
name - short, descriptive name, like "century".field - the field to wrap, like "year()".unitDivisor - divisor in units, such as 100 years in a century
java.lang.IllegalArgumentException - if unit is less than two| Method Detail |
public int get(long millis)
get in class DateTimeFieldmillis - the time instant in millis to query.
public long add(long millis,
int amount)
add in class DateTimeFieldmillis - the time instant in millis to update.amount - the amount of divided units to add (can be negative).
public long add(long millis,
long amount)
add in class DateTimeFieldmillis - the time instant in millis to update.amount - the amount of divided units to add (can be negative).
DateTimeField.add(long,int)
public long addWrapped(long millis,
int amount)
addWrapped in class DateTimeFieldmillis - the time instant in millis to update.amount - the amount of divided units to add (can be negative).
public long getDifference(long minuendMillis,
long subtrahendMillis)
DateTimeFieldlong millis = ... int v = ... long age = getDifference(add(millis, v), millis);The value 'age' is the same as the value 'v'.
The default implementation performs a guess-and-check algorithm using the getUnitMillis and add methods. Subclasses are encouraged to provide a more efficient implementation.
getDifference in class DateTimeFieldminuendMillis - the milliseconds from 1970-01-01T00:00:00Z to
subtract fromsubtrahendMillis - the milliseconds from 1970-01-01T00:00:00Z to
subtract off the minuend
public long set(long millis,
int value)
set in class DateTimeFieldmillis - the time instant in millis to update.value - value of divided units to set.
java.lang.IllegalArgumentException - if value is too large or too small.public long getUnitMillis()
getUnitMillis in class DateTimeFieldpublic long getRangeMillis()
getRangeMillis in class DateTimeFieldpublic int getMinimumValue()
getMinimumValue in class DateTimeFieldpublic int getMaximumValue()
getMaximumValue in class DateTimeFieldpublic long roundFloor(long millis)
DateTimeFieldFor 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 DateTimeFieldmillis - the milliseconds from 1970-01-01T00:00:00Z to round
public long remainder(long millis)
DateTimeFieldFor example, a datetime of 2002-11-02T23:34:56.789, the remainder by hour is 1970-01-01T00:34:56.789.
The default implementation computes
millis - roundFloor(millis). Subclasses are encouraged to
provide a more efficient implementation.
remainder in class DateTimeFieldmillis - the milliseconds from 1970-01-01T00:00:00Z to get the
remainder
public DateTimeField getField()
public int getUnitDivisor()
|
Joda Time API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||