Package org.joda.time.field
Class PreciseDurationDateTimeField
- java.lang.Object
-
- org.joda.time.DateTimeField
-
- org.joda.time.field.BaseDateTimeField
-
- org.joda.time.field.PreciseDurationDateTimeField
-
- Direct Known Subclasses:
PreciseDateTimeField
public abstract class PreciseDurationDateTimeField extends BaseDateTimeField
Precise datetime field, which has a precise unit duration field.PreciseDurationDateTimeField is thread-safe and immutable, and its subclasses must be as well.
- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description PreciseDurationDateTimeField(DateTimeFieldType type, DurationField unit)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DurationField
getDurationField()
Returns the duration per unit value of this field.int
getMinimumValue()
Get the minimum value for the field.long
getUnitMillis()
boolean
isLenient()
Returns false by default.long
remainder(long instant)
This method assumes that this field is properly rounded on 1970-01-01T00:00:00.long
roundCeiling(long instant)
This method assumes that this field is properly rounded on 1970-01-01T00:00:00.long
roundFloor(long instant)
This method assumes that this field is properly rounded on 1970-01-01T00:00:00.long
set(long instant, int value)
Set the specified amount of units to the specified time instant.-
Methods inherited from class org.joda.time.field.BaseDateTimeField
add, add, add, addWrapField, addWrapField, addWrapPartial, get, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsText, getAsText, getAsText, getAsText, getAsText, getDifference, getDifferenceAsLong, getLeapAmount, getLeapDurationField, getMaximumShortTextLength, getMaximumTextLength, getMaximumValue, getMaximumValue, getMaximumValue, getMaximumValue, getMinimumValue, getMinimumValue, getMinimumValue, getName, getRangeDurationField, getType, isLeap, isSupported, roundHalfCeiling, roundHalfEven, roundHalfFloor, set, set, set, set, toString
-
Methods inherited from class org.joda.time.DateTimeField
setExtended
-
-
-
-
Constructor Detail
-
PreciseDurationDateTimeField
public PreciseDurationDateTimeField(DateTimeFieldType type, DurationField unit)
Constructor.- Parameters:
type
- the field typeunit
- precise unit duration, like "days()".- Throws:
java.lang.IllegalArgumentException
- if duration field is imprecisejava.lang.IllegalArgumentException
- if unit milliseconds is less than one
-
-
Method Detail
-
isLenient
public boolean isLenient()
Returns false by default.- Specified by:
isLenient
in classDateTimeField
- Returns:
- true if this field is lenient
-
set
public long set(long instant, int value)
Set the specified amount of units to the specified time instant.- Specified by:
set
in classBaseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to set invalue
- value of units to set.- Returns:
- the updated time instant.
- Throws:
java.lang.IllegalArgumentException
- if value is too large or too small.
-
roundFloor
public long roundFloor(long instant)
This method assumes that this field is properly rounded on 1970-01-01T00:00:00. If the rounding alignment differs, override this method as follows:return super.roundFloor(instant + ALIGNMENT_MILLIS) - ALIGNMENT_MILLIS;
- Specified by:
roundFloor
in classBaseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to round- Returns:
- rounded milliseconds
-
roundCeiling
public long roundCeiling(long instant)
This method assumes that this field is properly rounded on 1970-01-01T00:00:00. If the rounding alignment differs, override this method as follows:return super.roundCeiling(instant + ALIGNMENT_MILLIS) - ALIGNMENT_MILLIS;
- Overrides:
roundCeiling
in classBaseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to round- Returns:
- rounded milliseconds
-
remainder
public long remainder(long instant)
This method assumes that this field is properly rounded on 1970-01-01T00:00:00. If the rounding alignment differs, override this method as follows:return super.remainder(instant + ALIGNMENT_MILLIS);
- Overrides:
remainder
in classBaseDateTimeField
- Parameters:
instant
- the milliseconds from 1970-01-01T00:00:00Z to get the remainder- Returns:
- remainder duration, in milliseconds
-
getDurationField
public DurationField getDurationField()
Returns the duration per unit value of this field. For example, if this field represents "minute of hour", then the duration field is minutes.- Specified by:
getDurationField
in classBaseDateTimeField
- Returns:
- the duration of this field, or UnsupportedDurationField if field has no duration
-
getMinimumValue
public int getMinimumValue()
Get the minimum value for the field.- Specified by:
getMinimumValue
in classBaseDateTimeField
- Returns:
- the minimum value
-
getUnitMillis
public final long getUnitMillis()
-
-