Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.joda.time
Class LocalDate.Property

    java.lang.Object
      org.joda.time.field.AbstractReadableInstantFieldProperty
          org.joda.time.LocalDate.Property

All Implemented Interfaces:
  java.io.Serializable

Enclosing class:
  LocalDate

    public static final class LocalDate.Property

extends AbstractReadableInstantFieldProperty

LocalDate.Property binds a LocalDate to a DateTimeField allowing powerful datetime functionality to be easily accessed.

The simplest use of this class is as an alternative get method, here used to get the year '1972' (as an int) and the month 'December' (as a String).

     LocalDate dt = new LocalDate(1972, 12, 3, 0, 0);
     int year = dt.year().get();
     String monthStr = dt.month().getAsText();

Methods are also provided that allow date modification. These return new instances of LocalDate - they do not modify the original. The example below yields two independent immutable date objects 20 years apart.

     LocalDate dt = new LocalDate(1972, 12, 3);
     LocalDate dt1920 = dt.year().setCopy(1920);

LocalDate.Property itself is thread-safe and immutable, as well as the LocalDate being operated on.

Since:
  1.3
Author:
  Stephen Colebourne, Brian S O'Neill
See Also:
  Serialized Form

Method Summary
`LocalDate` | `addToCopy(int value)` Adds to this field in a copy of this LocalDate.
`LocalDate` | `addWrapFieldToCopy(int value)` Adds to this field, possibly wrapped, in a copy of this LocalDate.
`protected Chronology` | `getChronology()` Gets the chronology of the datetime that this property is linked to.
`DateTimeField` | `getField()` Gets the field being used.
`LocalDate` | `getLocalDate()` Gets the LocalDate object linked to this property.
`protected long` | `getMillis()` Gets the milliseconds of the date that this property is linked to.
`LocalDate` | `roundCeilingCopy()` Rounds to the highest whole unit of this field on a copy of this LocalDate.
`LocalDate` | `roundFloorCopy()` Rounds to the lowest whole unit of this field on a copy of this LocalDate.
`LocalDate` | `roundHalfCeilingCopy()` Rounds to the nearest whole unit of this field on a copy of this LocalDate, favoring the ceiling if halfway.
`LocalDate` | `roundHalfEvenCopy()` Rounds to the nearest whole unit of this field on a copy of this LocalDate.
`LocalDate` | `roundHalfFloorCopy()` Rounds to the nearest whole unit of this field on a copy of this LocalDate, favoring the floor if halfway.
`LocalDate` | `setCopy(int value)` Sets this field in a copy of the LocalDate.
`LocalDate` | `setCopy(java.lang.String text)` Sets this field in a copy of the LocalDate to a parsed text value.
`LocalDate` | `setCopy(java.lang.String text, java.util.Locale locale)` Sets this field in a copy of the LocalDate to a parsed text value.
`LocalDate` | `withMaximumValue()` Returns a new LocalDate with this field set to the maximum value for this field.
`LocalDate` | `withMinimumValue()` Returns a new LocalDate with this field set to the minimum value for this field.

Methods inherited from class org.joda.time.field.AbstractReadableInstantFieldProperty
`compareTo, compareTo, equals, get, getAsShortText, getAsShortText, getAsString, getAsText, getAsText, getDifference, getDifferenceAsLong, getDurationField, getFieldType, getLeapAmount, getLeapDurationField, getMaximumShortTextLength, getMaximumTextLength, getMaximumValue, getMaximumValueOverall, getMinimumValue, getMinimumValueOverall, getName, getRangeDurationField, hashCode, isLeap, remainder, toInterval, toString`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Method Detail

### getField

    public DateTimeField getField()

  Gets the field being used.

  Specified by:
    `getField` in class `AbstractReadableInstantFieldProperty`
  Returns:
    the field

### getMillis

    protected long getMillis()

  Gets the milliseconds of the date that this property is linked to.

  Specified by:
    `getMillis` in class `AbstractReadableInstantFieldProperty`
  Returns:
    the milliseconds

### getChronology

    protected Chronology getChronology()

  Gets the chronology of the datetime that this property is linked to.

  Overrides:
    `getChronology` in class `AbstractReadableInstantFieldProperty`
  Returns:
    the chronology
  Since:
    1.4

### getLocalDate

    public LocalDate getLocalDate()

  Gets the LocalDate object linked to this property.

  Returns:
    the linked LocalDate

### addToCopy

    public LocalDate addToCopy(int value)

  Adds to this field in a copy of this LocalDate.

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

  Parameters:
    `value` - the value to add to the field in the copy
  Returns:
    a copy of the LocalDate with the field value changed
  Throws:
    `java.lang.IllegalArgumentException` - if the value isn't valid

### addWrapFieldToCopy

    public LocalDate addWrapFieldToCopy(int value)

  Adds to this field, possibly wrapped, in a copy of this LocalDate. A field wrapped operation only changes this field. Thus 31st January addWrapField one day goes to the 1st January.

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

  Parameters:
    `value` - the value to add to the field in the copy
  Returns:
    a copy of the LocalDate with the field value changed
  Throws:
    `java.lang.IllegalArgumentException` - if the value isn't valid

### setCopy

    public LocalDate setCopy(int value)

  Sets this field in a copy of the LocalDate.

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

  Parameters:
    `value` - the value to set the field in the copy to
  Returns:
    a copy of the LocalDate with the field value changed
  Throws:
    `java.lang.IllegalArgumentException` - if the value isn't valid

### setCopy

    public LocalDate setCopy(java.lang.String text,
                             java.util.Locale locale)

  Sets this field in a copy of the LocalDate to a parsed text value.

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

  Parameters:
    `text` - the text value to set
    `locale` - optional locale to use for selecting a text symbol
  Returns:
    a copy of the LocalDate with the field value changed
  Throws:
    `java.lang.IllegalArgumentException` - if the text value isn't valid

### setCopy

    public LocalDate setCopy(java.lang.String text)

  Sets this field in a copy of the LocalDate to a parsed text value.

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

  Parameters:
    `text` - the text value to set
  Returns:
    a copy of the LocalDate with the field value changed
  Throws:
    `java.lang.IllegalArgumentException` - if the text value isn't valid

### withMaximumValue

    public LocalDate withMaximumValue()

  Returns a new LocalDate with this field set to the maximum value for this field.

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

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

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

  Returns:
    a copy of the LocalDate with this field set to its maximum

### withMinimumValue

    public LocalDate withMinimumValue()

  Returns a new LocalDate with this field set to the minimum value for this field.

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

  Returns:
    a copy of the LocalDate with this field set to its minimum

### roundFloorCopy

    public LocalDate roundFloorCopy()

  Rounds to the lowest whole unit of this field on a copy of this LocalDate.

  For example, rounding floor on the hourOfDay field of a LocalDate where the time is 10:30 would result in new LocalDate with the time of 10:00.

  Returns:
    a copy of the LocalDate with the field value changed

### roundCeilingCopy

    public LocalDate roundCeilingCopy()

  Rounds to the highest whole unit of this field on a copy of this LocalDate.

  For example, rounding floor on the hourOfDay field of a LocalDate where the time is 10:30 would result in new LocalDate with the time of 11:00.

  Returns:
    a copy of the LocalDate with the field value changed

### roundHalfFloorCopy

    public LocalDate roundHalfFloorCopy()

  Rounds to the nearest whole unit of this field on a copy of this LocalDate, favoring the floor if halfway.

  Returns:
    a copy of the LocalDate with the field value changed

### roundHalfCeilingCopy

    public LocalDate roundHalfCeilingCopy()

  Rounds to the nearest whole unit of this field on a copy of this LocalDate, favoring the ceiling if halfway.

  Returns:
    a copy of the LocalDate with the field value changed

### roundHalfEvenCopy

    public LocalDate roundHalfEvenCopy()

  Rounds to the nearest whole unit of this field on a copy of this LocalDate. If halfway, the ceiling is favored over the floor only if it makes this field's value even.

  Returns:
    a copy of the LocalDate with the field value changed

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD