org.joda.time.field

Class SkipDateTimeField

Implemented Interfaces:
Serializable

public final class SkipDateTimeField
extends DelegatedDateTimeField

Wraps another field such that a certain value is skipped.

This is most useful for years where you want to skip zero, so the sequence runs ...,2,1,-1,-2,...

SkipDateTimeField is thread-safe and immutable.

Authors:
Brian S O'Neill
Stephen Colebourne
Since:
1.0

Constructor Summary

SkipDateTimeField(Chronology chronology, DateTimeField field)
Constructor that skips zero.
SkipDateTimeField(Chronology chronology, DateTimeField field, int skip)
Constructor.

Method Summary

int
get(long millis)
Get the value of this field from the milliseconds.
int
getMinimumValue()
Get the minimum allowable value for this field.
long
set(long millis, int value)
Sets a value in the milliseconds supplied.

Methods inherited from class org.joda.time.field.DelegatedDateTimeField

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, getWrappedField, isLeap, isLenient, 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

SkipDateTimeField

public SkipDateTimeField(Chronology chronology,
                         DateTimeField field)
Constructor that skips zero.
Parameters:
chronology - the chronoogy to use
field - the field to skip zero on

SkipDateTimeField

public SkipDateTimeField(Chronology chronology,
                         DateTimeField field,
                         int skip)
Constructor.
Parameters:
chronology - the chronoogy to use
field - the field to skip zero on
skip - the value to skip

Method Details

get

public int get(long millis)
Get the value of this field from the milliseconds.
Overrides:
get in interface DelegatedDateTimeField
Parameters:
Returns:
the value of the field, in the units of the field

getMinimumValue

public int getMinimumValue()
Get the minimum allowable value for this field.
Overrides:
getMinimumValue in interface DelegatedDateTimeField
Returns:
the minimum valid value for this field, in the units of the field

set

public long set(long millis,
                int value)
Sets a value in the milliseconds supplied.

The value of this field will be set. If the value is invalid, an exception if thrown.

If setting this field would make other fields invalid, then those fields may be changed. For example if the current date is the 31st January, and the month is set to February, the day would be invalid. Instead, the day would be changed to the closest value - the 28th/29th February as appropriate.

Overrides:
set in interface DelegatedDateTimeField
Parameters:
value - the value to set, in the units of the field
Returns:
the updated milliseconds

Copyright (c) 2001-2006 - Joda.org