org.joda.time.field

Class PreciseDurationDateTimeField

Known Direct 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.

Author:
Brian S O'Neill
Since:
1.0

Constructor Summary

PreciseDurationDateTimeField(DateTimeFieldType type, DurationField unit)
Constructor.

Method Summary

DurationField
getDurationField()
Returns the duration per unit value of this field.
protected int
getMaximumValueForSet(long instant, int value)
Called by the set method to get the maximum allowed value.
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, convertText, get, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsText, getAsText, getAsText, getAsText, getAsText, getDifference, getDifferenceAsLong, getDurationField, getLeapAmount, getLeapDurationField, getMaximumShortTextLength, getMaximumTextLength, getMaximumValue, getMaximumValue, getMaximumValue, getMaximumValue, getMinimumValue, getMinimumValue, getMinimumValue, getMinimumValue, getName, getRangeDurationField, getType, isLeap, isSupported, remainder, roundCeiling, roundFloor, roundHalfCeiling, roundHalfEven, roundHalfFloor, set, set, set, set, set, toString

Methods inherited from class org.joda.time.DateTimeField

add, add, add, addWrapField, addWrapField, addWrapPartial, get, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsShortText, getAsText, getAsText, getAsText, getAsText, getAsText, getDifference, getDifferenceAsLong, getDurationField, getLeapAmount, getLeapDurationField, getMaximumShortTextLength, getMaximumTextLength, getMaximumValue, getMaximumValue, getMaximumValue, getMaximumValue, getMinimumValue, getMinimumValue, getMinimumValue, getMinimumValue, getName, getRangeDurationField, getType, isLeap, isLenient, isSupported, remainder, roundCeiling, roundFloor, roundHalfCeiling, roundHalfEven, roundHalfFloor, set, set, set, set, set, toString

Constructor Details

PreciseDurationDateTimeField

public PreciseDurationDateTimeField(DateTimeFieldType type,
                                    DurationField unit)
Constructor.
Parameters:
type - the field type
unit - precise unit duration, like "days()".

Method Details

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.
Overrides:
getDurationField in interface BaseDateTimeField
Returns:
the duration of this field, or UnsupportedDurationField if field has no duration

getMaximumValueForSet

protected int getMaximumValueForSet(long instant,
                                    int value)
Called by the set method to get the maximum allowed value. By default, returns getMaximumValue(instant). Override to provide a faster implementation.

getMinimumValue

public int getMinimumValue()
Get the minimum value for the field.
Overrides:
getMinimumValue in interface BaseDateTimeField
Returns:
the minimum value

getUnitMillis

public final long getUnitMillis()

isLenient

public boolean isLenient()
Returns false by default.
Overrides:
isLenient in interface DateTimeField

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 interface BaseDateTimeField

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 interface BaseDateTimeField

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;
 
Overrides:
roundFloor in interface BaseDateTimeField

set

public long set(long instant,
                int value)
Set the specified amount of units to the specified time instant.
Overrides:
set in interface BaseDateTimeField
Parameters:
instant - the milliseconds from 1970-01-01T00:00:00Z to set in
value - value of units to set.
Returns:
the updated time instant.

Copyright (c) 2001-2006 - Joda.org