org.joda.time.field
Class PreciseDurationDateTimeField

java.lang.Object
  extended by org.joda.time.DateTimeField
      extended by org.joda.time.field.BaseDateTimeField
          extended by 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
Author:
Brian S O'Neill

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, 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PreciseDurationDateTimeField

public PreciseDurationDateTimeField(DateTimeFieldType type,
                                    DurationField unit)
Constructor.

Parameters:
type - the field type
unit - precise unit duration, like "days()".
Throws:
IllegalArgumentException - if duration field is imprecise
IllegalArgumentException - if unit milliseconds is less than one
Method Detail

isLenient

public boolean isLenient()
Returns false by default.

Specified by:
isLenient in class DateTimeField
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 class 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.
Throws:
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 class BaseDateTimeField
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 class BaseDateTimeField
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 class BaseDateTimeField
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 class BaseDateTimeField
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 class BaseDateTimeField
Returns:
the minimum value

getUnitMillis

public final long getUnitMillis()

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.



Copyright © 2002-2012 Joda.org. All Rights Reserved.