|
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.LimitDateTimeField
Generic limiting datetime field.
This DateTimeField allows specific millisecond boundaries to be applied to DateTimeFields.
| Constructor Summary | |
LimitDateTimeField(java.lang.String name,
DateTimeField field,
long lowerBound,
long upperBound)
Constructor |
|
| Method Summary | |
long |
add(long millis,
int amount)
Add the specified amount of fractional units to the specified time instant. |
long |
add(long millis,
long amount)
Add the specified amount of fractional units to the specified time instant. |
long |
addWrapped(long millis,
int amount)
Add to the fractional component of the specified time instant, wrapping around within that component if necessary. |
int |
get(long millis)
Get the amount of fractional units from the specified time instant. |
java.lang.String |
getAsShortText(long millis,
java.util.Locale locale)
Get the human-readable, short text value of this field from the milliseconds. |
java.lang.String |
getAsText(long millis,
java.util.Locale locale)
Get the human-readable, text value of this field from the milliseconds. |
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. |
long |
getLowerBound()
Returns the milliseconds lower bound. |
int |
getMaximumShortTextLength(java.util.Locale locale)
Get the maximum short text value for this field. |
int |
getMaximumTextLength(java.util.Locale locale)
Get the maximum text value for this field. |
int |
getMaximumValue()
Get the maximum value for the field. |
int |
getMinimumValue()
Get the minimum value for the field. |
long |
getRangeMillis()
Returns the range of this field, in milliseconds. |
long |
getUnitMillis()
Returns the amount of milliseconds per unit value of this field. |
long |
getUpperBound()
Returns the milliseconds upper bound. |
long |
remainder(long millis)
Retains only the fractional units of this field. |
long |
roundCeiling(long millis)
Round to the highest whole unit of this field. |
long |
roundFloor(long millis)
Round to the lowest whole unit of this field. |
long |
roundHalfCeiling(long millis)
Round to the nearest whole unit of this field. |
long |
roundHalfEven(long millis)
Round to the nearest whole unit of this field. |
long |
roundHalfFloor(long millis)
Round to the nearest whole unit of this field. |
long |
set(long millis,
int value)
Set the specified amount of fractional units to the specified time instant. |
long |
set(long millis,
java.lang.String text,
java.util.Locale locale)
Sets a value in the milliseconds supplied from a human-readable, text value. |
| Methods inherited from class org.joda.time.DateTimeField |
addLong, getAsShortText, getAsText, getLeapAmount, getMaximumValue, getMinimumValue, getName, getWrappedValue, getWrappedValue, isLeap, set, toString, verifyValueBounds |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public LimitDateTimeField(java.lang.String name,
DateTimeField field,
long lowerBound,
long upperBound)
name - short, descriptive name, like "secondOfMinute".lowerBound - milliseconds to form the lower boundary inclusiveupperBound - milliseconds to form the upper boundary inclusive
java.lang.IllegalArgumentException - if field is null or boundary is invalid| Method Detail |
public int get(long millis)
get in class DateTimeFieldmillis - the time instant in millis to query.
public java.lang.String getAsText(long millis,
java.util.Locale locale)
DateTimeFieldThe default implementation returns Integer.toString(get(millis)).
Note: subclasses that override this method should also override getMaximumTextLength.
getAsText in class DateTimeFieldmillis - the milliseconds from 1970-01-01T00:00:00Z to querylocale - the locale to use for selecting a text symbol, null for
default
public java.lang.String getAsShortText(long millis,
java.util.Locale locale)
DateTimeFieldThe default implementation returns getAsText(millis, locale).
Note: subclasses that override this method should also override getMaximumShortTextLength.
getAsShortText in class DateTimeFieldmillis - the milliseconds from 1970-01-01T00:00:00Z to querylocale - the locale to use for selecting a text symbol, null for
default
public long add(long millis,
int amount)
add in class DateTimeFieldmillis - the time instant in millis to update.amount - the amount of fractional 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 fractional 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 fractional 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 fractional units to set.
java.lang.IllegalArgumentException - if value is too large or too small.
public long set(long millis,
java.lang.String text,
java.util.Locale locale)
DateTimeFieldThe default implementation returns set(millis, Integer.parseInt(millis)).
Note: subclasses that override this method should also override getAsText.
set in class DateTimeFieldmillis - the milliseconds from 1970-01-01T00:00:00Z to set intext - the text value to setlocale - the locale to use for selecting a text symbol, null for
default
public long getUnitMillis()
DateTimeFieldFor fields with a variable unit size, this method returns a suitable average value.
getUnitMillis in class DateTimeFieldpublic long getRangeMillis()
DateTimeFieldFor fields with a variable range, this method returns a suitable average value. If the range is too large to fit in a long, Long.MAX_VALUE is returned.
getRangeMillis in class DateTimeFieldpublic int getMinimumValue()
getMinimumValue in class DateTimeFieldpublic int getMaximumValue()
getMaximumValue in class DateTimeFieldpublic int getMaximumTextLength(java.util.Locale locale)
DateTimeField
getMaximumTextLength in class DateTimeFieldlocale - the locale to use for selecting a text symbol
public int getMaximumShortTextLength(java.util.Locale locale)
DateTimeField
getMaximumShortTextLength in class DateTimeFieldlocale - the locale to use for selecting a text symbol
public 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 roundCeiling(long millis)
DateTimeFieldFor 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 millis is modified as a result, adds one field unit. Subclasses are encouraged to provide a more efficient implementation.
roundCeiling in class DateTimeFieldmillis - the milliseconds from 1970-01-01T00:00:00Z to round
public long roundHalfFloor(long millis)
DateTimeField
roundHalfFloor in class DateTimeFieldmillis - the milliseconds from 1970-01-01T00:00:00Z to round
public long roundHalfCeiling(long millis)
DateTimeField
roundHalfCeiling in class DateTimeFieldmillis - the milliseconds from 1970-01-01T00:00:00Z to round
public long roundHalfEven(long millis)
DateTimeFieldIf 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 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 long getLowerBound()
public long getUpperBound()
|
Joda Time API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||