org.joda.time.field

Class PreciseDateTimeField


public class PreciseDateTimeField
extends PreciseDurationDateTimeField

Precise datetime field, composed of two precise duration fields.

This DateTimeField is useful for defining DateTimeFields that are composed of precise durations, like time of day fields. If either duration field is imprecise, then an ImpreciseDateTimeField may be used instead.

PreciseDateTimeField is thread-safe and immutable.

Authors:
Brian S O'Neill
Stephen Colebourne
Since:
1.0
See Also:
ImpreciseDateTimeField

Constructor Summary

PreciseDateTimeField(DateTimeFieldType type, DurationField unit, DurationField range)
Constructor.

Method Summary

long
addWrapField(long instant, int amount)
Add to the component of the specified time instant, wrapping around within that component if necessary.
int
get(long instant)
Get the amount of fractional units from the specified time instant.
int
getMaximumValue()
Get the maximum value for the field.
int
getRange()
Returns the range of the field in the field's units.
DurationField
getRangeDurationField()
Returns the range duration of this field.
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.PreciseDurationDateTimeField

getDurationField, getMaximumValueForSet, getMinimumValue, getUnitMillis, isLenient, remainder, roundCeiling, roundFloor, set

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

PreciseDateTimeField

public PreciseDateTimeField(DateTimeFieldType type,
                            DurationField unit,
                            DurationField range)
Constructor.
Parameters:
type - the field type this field uses
unit - precise unit duration, like "seconds()".
range - precise range duration, preferably a multiple of the unit, like "minutes()".

Method Details

addWrapField

public long addWrapField(long instant,
                         int amount)
Add to the component of the specified time instant, wrapping around within that component if necessary.
Overrides:
addWrapField in interface BaseDateTimeField
Parameters:
instant - the milliseconds from 1970-01-01T00:00:00Z to add to
amount - the amount of units to add (can be negative).
Returns:
the updated time instant.

get

public int get(long instant)
Get the amount of fractional units from the specified time instant.
Overrides:
get in interface BaseDateTimeField
Parameters:
instant - the milliseconds from 1970-01-01T00:00:00Z to query
Returns:
the amount of fractional units extracted from the input.

getMaximumValue

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

getRange

public int getRange()
Returns the range of the field in the field's units.

For example, 60 for seconds per minute. The field is allowed values from 0 to range - 1.

Returns:
unit range

getRangeDurationField

public DurationField getRangeDurationField()
Returns the range duration of this field. For example, if this field represents "minute of hour", then the range duration field is an hours.
Overrides:
getRangeDurationField in interface BaseDateTimeField
Returns:
the range duration of this field, or null if field has no range

set

public long set(long instant,
                int value)
Set the specified amount of units to the specified time instant.
Overrides:
set in interface PreciseDurationDateTimeField
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