org.joda.time.field

Class StrictDateTimeField

Implemented Interfaces:
Serializable

public class StrictDateTimeField
extends DelegatedDateTimeField

Converts a lenient DateTimeField into a strict one. By being strict, the set throws an IllegalArgumentException if the value is out of bounds.

StrictDateTimeField is thread-safe and immutable.

Author:
Brian S O'Neill
Since:
1.0
See Also:
StrictChronology, LenientDateTimeField

Constructor Summary

StrictDateTimeField(DateTimeField field)

Method Summary

static DateTimeField
getInstance(DateTimeField field)
Returns a strict version of the given field.
boolean
isLenient()
Returns true if the set method is lenient.
long
set(long instant, int value)
Does a bounds check before setting the value.

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

StrictDateTimeField

protected StrictDateTimeField(DateTimeField field)

Method Details

getInstance

public static DateTimeField getInstance(DateTimeField field)
Returns a strict version of the given field. If it is already strict, then it is returned as-is. Otherwise, a new StrictDateTimeField is returned.

isLenient

public final boolean isLenient()
Returns true if the set method is lenient. If so, it accepts values that are out of bounds. For example, a lenient day of month field accepts 32 for January, converting it to February 1.
Overrides:
isLenient in interface DelegatedDateTimeField
Returns:
true if this field is lenient

set

public long set(long instant,
                int value)
Does a bounds check before setting the value.
Overrides:
set in interface DelegatedDateTimeField

Copyright (c) 2001-2006 - Joda.org