org.joda.time

Class YearMonthDay.Property

Enclosing Class:
YearMonthDay
Implemented Interfaces:
Serializable

public static class YearMonthDay.Property
extends AbstractPartialFieldProperty
implements Serializable

The property class for YearMonthDay.

This class binds a YearMonthDay to a DateTimeField.

Author:
Stephen Colebourne
Since:
1.0

Method Summary

YearMonthDay
addToCopy(int valueToAdd)
Adds to the value of this field in a copy of this YearMonthDay.
YearMonthDay
addWrapFieldToCopy(int valueToAdd)
Adds to the value of this field in a copy of this YearMonthDay wrapping within this field if the maximum value is reached.
int
get()
Gets the value of this field.
DateTimeField
getField()
Gets the field that this property uses.
protected ReadablePartial
getReadablePartial()
Gets the partial that this property belongs to.
YearMonthDay
getYearMonthDay()
Gets the partial that this property belongs to.
YearMonthDay
setCopy(String text)
Sets this field in a copy of the YearMonthDay to a parsed text value.
YearMonthDay
setCopy(String text, Locale locale)
Sets this field in a copy of the YearMonthDay to a parsed text value.
YearMonthDay
setCopy(int value)
Sets this field in a copy of the YearMonthDay.
YearMonthDay
withMaximumValue()
Returns a new YearMonthDay with this field set to the maximum value for this field.
YearMonthDay
withMinimumValue()
Returns a new YearMonthDay with this field set to the minimum value for this field.

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

compareTo, compareTo, equals, get, getAsShortText, getAsShortText, getAsString, getAsText, getAsText, getDurationField, getField, getFieldType, getMaximumShortTextLength, getMaximumTextLength, getMaximumValue, getMaximumValueOverall, getMinimumValue, getMinimumValueOverall, getName, getRangeDurationField, getReadablePartial, hashCode, toString

Method Details

addToCopy

public YearMonthDay addToCopy(int valueToAdd)
Adds to the value of this field in a copy of this YearMonthDay.

The value will be added to this field. If the value is too large to be added solely to this field then it will affect larger fields. Smaller fields are unaffected.

If the result would be too large, beyond the maximum year, then an IllegalArgumentException is thrown.

The YearMonthDay attached to this property is unchanged by this call. Instead, a new instance is returned.

Parameters:
valueToAdd - the value to add to the field in the copy
Returns:
a copy of the YearMonthDay with the field value changed

addWrapFieldToCopy

public YearMonthDay addWrapFieldToCopy(int valueToAdd)
Adds to the value of this field in a copy of this YearMonthDay wrapping within this field if the maximum value is reached.

The value will be added to this field. If the value is too large to be added solely to this field then it wraps within this field. Other fields are unaffected.

For example, 2004-12-20 addWrapField one month returns 2004-01-20.

The YearMonthDay attached to this property is unchanged by this call. Instead, a new instance is returned.

Parameters:
valueToAdd - the value to add to the field in the copy
Returns:
a copy of the YearMonthDay with the field value changed

get

public int get()
Gets the value of this field.
Overrides:
get in interface AbstractPartialFieldProperty
Returns:
the field value

getField

public DateTimeField getField()
Gets the field that this property uses.
Overrides:
getField in interface AbstractPartialFieldProperty
Returns:
the field

getReadablePartial

protected ReadablePartial getReadablePartial()
Gets the partial that this property belongs to.
Overrides:
getReadablePartial in interface AbstractPartialFieldProperty
Returns:
the partial

getYearMonthDay

public YearMonthDay getYearMonthDay()
Gets the partial that this property belongs to.
Returns:
the partial

setCopy

public YearMonthDay setCopy(String text)
Sets this field in a copy of the YearMonthDay to a parsed text value.

The YearMonthDay attached to this property is unchanged by this call. Instead, a new instance is returned.

Parameters:
text - the text value to set
Returns:
a copy of the YearMonthDay with the field value changed

setCopy

public YearMonthDay setCopy(String text,
                            Locale locale)
Sets this field in a copy of the YearMonthDay to a parsed text value.

The YearMonthDay attached to this property is unchanged by this call. Instead, a new instance is returned.

Parameters:
text - the text value to set
locale - optional locale to use for selecting a text symbol
Returns:
a copy of the YearMonthDay with the field value changed

setCopy

public YearMonthDay setCopy(int value)
Sets this field in a copy of the YearMonthDay.

The YearMonthDay attached to this property is unchanged by this call. Instead, a new instance is returned.

Parameters:
value - the value to set the field in the copy to
Returns:
a copy of the YearMonthDay with the field value changed

withMaximumValue

public YearMonthDay withMaximumValue()
Returns a new YearMonthDay with this field set to the maximum value for this field.

This operation is useful for obtaining a DateTime on the last day of the month, as month lengths vary.

 YearMonthDay lastDayOfMonth = dt.dayOfMonth().withMaximumValue();
 

The YearMonthDay attached to this property is unchanged by this call.

Returns:
a copy of the YearMonthDay with this field set to its maximum
Since:
1.2

withMinimumValue

public YearMonthDay withMinimumValue()
Returns a new YearMonthDay with this field set to the minimum value for this field.

The YearMonthDay attached to this property is unchanged by this call.

Returns:
a copy of the YearMonthDay with this field set to its minimum
Since:
1.2

Copyright (c) 2001-2006 - Joda.org