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

    java.lang.Object
      org.joda.time.base.AbstractPartial
          org.joda.time.base.BaseLocal
              org.joda.time.LocalDate

All Implemented Interfaces:
  java.io.Serializable, java.lang.Comparable, ReadablePartial

    public final class LocalDate

extends BaseLocal
implements ReadablePartial, java.io.Serializable

LocalDate is an immutable datetime class representing a date without a time zone.

LocalDate implements the `ReadablePartial` interface. To do this, the interface methods focus on the key fields - Year, MonthOfYear and DayOfMonth. However, all date fields may in fact be queried.

LocalDate differs from DateMidnight in that this class does not have a time zone and does not represent a single instant in time.

Calculations on LocalDate are performed using a `Chronology`. This chronology will be set internally to be in the UTC time zone for all calculations.

Each individual field can be queried in two ways:

- `getMonthOfYear()`
- `monthOfYear().get()`

The second technique also provides access to other useful methods on the field:

- numeric value
- text value
- short text value
- maximum/minimum values
- add/subtract
- set
- rounding

LocalDate is thread-safe and immutable, provided that the Chronology is as well. All standard Chronology classes supplied are thread-safe and immutable.

Since:
  1.3
Author:
  Stephen Colebourne
See Also:
  Serialized Form

Nested Class Summary
`static class` | `LocalDate.Property` LocalDate.Property binds a LocalDate to a DateTimeField allowing powerful datetime functionality to be easily accessed.

Constructor Summary
`LocalDate()` Constructs an instance set to the current local time evaluated using ISO chronology in the default zone.
`LocalDate(Chronology chronology)` Constructs an instance set to the current local time evaluated using specified chronology.
`LocalDate(DateTimeZone zone)` Constructs an instance set to the current local time evaluated using ISO chronology in the specified zone.
`LocalDate(int year, int monthOfYear, int dayOfMonth)` Constructs an instance set to the specified date and time using `ISOChronology`.
`LocalDate(int year, int monthOfYear, int dayOfMonth, Chronology chronology)` Constructs an instance set to the specified date and time using the specified chronology, whose zone is ignored.
`LocalDate(long instant)` Constructs an instance set to the local time defined by the specified instant evaluated using ISO chronology in the default zone.
`LocalDate(long instant, Chronology chronology)` Constructs an instance set to the local time defined by the specified instant evaluated using the specified chronology.
`LocalDate(long instant, DateTimeZone zone)` Constructs an instance set to the local time defined by the specified instant evaluated using ISO chronology in the specified zone.
`LocalDate(java.lang.Object instant)` Constructs an instance from an Object that represents a datetime.
`LocalDate(java.lang.Object instant, Chronology chronology)` Constructs an instance from an Object that represents a datetime, using the specified chronology.
`LocalDate(java.lang.Object instant, DateTimeZone zone)` Constructs an instance from an Object that represents a datetime, forcing the time zone to that specified.

Method Summary
`LocalDate.Property` | `centuryOfEra()` Get the century of era property which provides access to advanced functionality.
`int` | `compareTo(java.lang.Object partial)` Compares this partial with another returning an integer indicating the order.
`LocalDate.Property` | `dayOfMonth()` Get the day of month property which provides access to advanced functionality.
`LocalDate.Property` | `dayOfWeek()` Get the day of week property which provides access to advanced functionality.
`LocalDate.Property` | `dayOfYear()` Get the day of year property which provides access to advanced functionality.
`boolean` | `equals(java.lang.Object partial)` Compares this ReadablePartial with another returning true if the chronology, field types and values are equal.
`LocalDate.Property` | `era()` Get the era property which provides access to advanced functionality.
`static LocalDate` | `fromCalendarFields(java.util.Calendar calendar)` Constructs a LocalDate from a `java.util.Calendar` using exactly the same field values avoiding any time zone effects.
`static LocalDate` | `fromDateFields(java.util.Date date)` Constructs a LocalDate from a `java.util.Date` using exactly the same field values avoiding any time zone effects.
`int` | `get(DateTimeFieldType fieldType)` Get the value of one of the fields of a datetime.
`int` | `getCenturyOfEra()` Get the year of era field value.
`Chronology` | `getChronology()` Gets the chronology of the date.
`int` | `getDayOfMonth()` Get the day of month field value.
`int` | `getDayOfWeek()` Get the day of week field value.
`int` | `getDayOfYear()` Get the day of year field value.
`int` | `getEra()` Get the era field value.
`protected DateTimeField` | `getField(int index, Chronology chrono)` Gets the field for a specific index in the chronology specified.
`protected long` | `getLocalMillis()` Gets the local milliseconds from the Java epoch of 1970-01-01T00:00:00 (not fixed to any specific time zone).
`int` | `getMonthOfYear()` Get the month of year field value.
`int` | `getValue(int index)` Gets the value of the field at the specifed index.
`int` | `getWeekOfWeekyear()` Get the week of weekyear field value.
`int` | `getWeekyear()` Get the weekyear field value.
`int` | `getYear()` Get the year field value.
`int` | `getYearOfCentury()` Get the year of century field value.
`int` | `getYearOfEra()` Get the year of era field value.
`boolean` | `isSupported(DateTimeFieldType type)` Checks if the field type specified is supported by this local date and chronology.
`boolean` | `isSupported(DurationFieldType type)` Checks if the duration type specified is supported by this local date and chronology.
`LocalDate` | `minus(ReadablePeriod period)` Returns a copy of this date with the specified period taken away.
`LocalDate` | `minusDays(int days)` Returns a copy of this date minus the specified number of days.
`LocalDate` | `minusMonths(int months)` Returns a copy of this date minus the specified number of months.
`LocalDate` | `minusWeeks(int weeks)` Returns a copy of this date minus the specified number of weeks.
`LocalDate` | `minusYears(int years)` Returns a copy of this date minus the specified number of years.
`LocalDate.Property` | `monthOfYear()` Get the month of year property which provides access to advanced functionality.
`LocalDate` | `plus(ReadablePeriod period)` Returns a copy of this date with the specified period added.
`LocalDate` | `plusDays(int days)` Returns a copy of this date plus the specified number of days.
`LocalDate` | `plusMonths(int months)` Returns a copy of this date plus the specified number of months.
`LocalDate` | `plusWeeks(int weeks)` Returns a copy of this date plus the specified number of weeks.
`LocalDate` | `plusYears(int years)` Returns a copy of this date plus the specified number of years.
`LocalDate.Property` | `property(DateTimeFieldType fieldType)` Gets the property object for the specified type, which contains many useful methods.
`int` | `size()` Gets the number of fields in this partial, which is three.
`DateMidnight` | `toDateMidnight()` Converts this LocalDate to a DateMidnight in the default time zone.
`DateMidnight` | `toDateMidnight(DateTimeZone zone)` Converts this LocalDate to a DateMidnight.
`DateTime` | `toDateTime(LocalTime time)` Converts this object to a DateTime using a LocalTime to fill in the missing fields and using the default time zone.
`DateTime` | `toDateTime(LocalTime time, DateTimeZone zone)` Converts this object to a DateTime using a LocalTime to fill in the missing fields.
`DateTime` | `toDateTimeAtCurrentTime()` Converts this LocalDate to a full datetime using the default time zone setting the date fields from this instance and the time fields from the current time.
`DateTime` | `toDateTimeAtCurrentTime(DateTimeZone zone)` Converts this LocalDate to a full datetime using the specified time zone setting the date fields from this instance and the time fields from the current time.
`DateTime` | `toDateTimeAtMidnight()` Deprecated. Use `toDateTimeAtStartOfDay()` which won't throw an exception
`DateTime` | `toDateTimeAtMidnight(DateTimeZone zone)` Deprecated. Use `toDateTimeAtStartOfDay(DateTimeZone)` which won't throw an exception
`DateTime` | `toDateTimeAtStartOfDay()` Converts this LocalDate to a full datetime at the earliest valid time for the date using the default time zone.
`DateTime` | `toDateTimeAtStartOfDay(DateTimeZone zone)` Converts this LocalDate to a full datetime at the earliest valid time for the date using the specified time zone.
`Interval` | `toInterval()` Converts this object to an Interval representing the whole day in the default time zone.
`Interval` | `toInterval(DateTimeZone zone)` Converts this object to an Interval representing the whole day.
`LocalDateTime` | `toLocalDateTime(LocalTime time)` Converts this object to a LocalDateTime using a LocalTime to fill in the missing fields.
`java.lang.String` | `toString()` Output the date time in ISO8601 format (yyyy-MM-dd).
`java.lang.String` | `toString(java.lang.String pattern)` Output the date using the specified format pattern.
`java.lang.String` | `toString(java.lang.String pattern, java.util.Locale locale)` Output the date using the specified format pattern.
`LocalDate.Property` | `weekOfWeekyear()` Get the week of a week based year property which provides access to advanced functionality.
`LocalDate.Property` | `weekyear()` Get the weekyear property which provides access to advanced functionality.
`LocalDate` | `withCenturyOfEra(int centuryOfEra)` Returns a copy of this date with the century of era field updated.
`LocalDate` | `withDayOfMonth(int dayOfMonth)` Returns a copy of this date with the day of month field updated.
`LocalDate` | `withDayOfWeek(int dayOfWeek)` Returns a copy of this date with the day of week field updated.
`LocalDate` | `withDayOfYear(int dayOfYear)` Returns a copy of this date with the day of year field updated.
`LocalDate` | `withEra(int era)` Returns a copy of this date with the era field updated.
`LocalDate` | `withField(DateTimeFieldType fieldType, int value)` Returns a copy of this date with the specified field set to a new value.
`LocalDate` | `withFieldAdded(DurationFieldType fieldType, int amount)` Returns a copy of this date with the value of the specified field increased.
`LocalDate` | `withFields(ReadablePartial partial)` Returns a copy of this date with the partial set of fields replacing those from this instance.
`LocalDate` | `withMonthOfYear(int monthOfYear)` Returns a copy of this date with the month of year field updated.
`LocalDate` | `withPeriodAdded(ReadablePeriod period, int scalar)` Returns a copy of this date with the specified period added.
`LocalDate` | `withWeekOfWeekyear(int weekOfWeekyear)` Returns a copy of this date with the week of weekyear field updated.
`LocalDate` | `withWeekyear(int weekyear)` Returns a copy of this date with the weekyear field updated.
`LocalDate` | `withYear(int year)` Returns a copy of this date with the year field updated.
`LocalDate` | `withYearOfCentury(int yearOfCentury)` Returns a copy of this date with the year of century field updated.
`LocalDate` | `withYearOfEra(int yearOfEra)` Returns a copy of this date with the year of era field updated.
`LocalDate.Property` | `year()` Get the year property which provides access to advanced functionality.
`LocalDate.Property` | `yearOfCentury()` Get the year of century property which provides access to advanced functionality.
`LocalDate.Property` | `yearOfEra()` Get the year of era property which provides access to advanced functionality.

Methods inherited from class org.joda.time.base.AbstractPartial
`getField, getFields, getFieldType, getFieldTypes, getValues, hashCode, indexOf, indexOf, indexOfSupported, indexOfSupported, isAfter, isBefore, isEqual, toDateTime, toString`

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

Methods inherited from interface org.joda.time.ReadablePartial
`getField, getFieldType, hashCode, toDateTime`

Constructor Detail

### LocalDate

    public LocalDate()

  Constructs an instance set to the current local time evaluated using ISO chronology in the default zone.

  Once the constructor is completed, the zone is no longer used.

### LocalDate

    public LocalDate(DateTimeZone zone)

  Constructs an instance set to the current local time evaluated using ISO chronology in the specified zone.

  If the specified time zone is null, the default zone is used. Once the constructor is completed, the zone is no longer used.

  Parameters:
    `zone` - the time zone, null means default zone

### LocalDate

    public LocalDate(Chronology chronology)

  Constructs an instance set to the current local time evaluated using specified chronology.

  If the chronology is null, ISO chronology in the default time zone is used. Once the constructor is completed, the zone is no longer used.

  Parameters:
    `chronology` - the chronology, null means ISOChronology in default zone

### LocalDate

    public LocalDate(long instant)

  Constructs an instance set to the local time defined by the specified instant evaluated using ISO chronology in the default zone.

  Once the constructor is completed, the zone is no longer used.

  Parameters:
    `instant` - the milliseconds from 1970-01-01T00:00:00Z

### LocalDate

    public LocalDate(long instant,
                     DateTimeZone zone)

  Constructs an instance set to the local time defined by the specified instant evaluated using ISO chronology in the specified zone.

  If the specified time zone is null, the default zone is used. Once the constructor is completed, the zone is no longer used.

  Parameters:
    `instant` - the milliseconds from 1970-01-01T00:00:00Z
    `zone` - the time zone, null means default zone

### LocalDate

    public LocalDate(long instant,
                     Chronology chronology)

  Constructs an instance set to the local time defined by the specified instant evaluated using the specified chronology.

  If the chronology is null, ISO chronology in the default zone is used. Once the constructor is completed, the zone is no longer used.

  Parameters:
    `instant` - the milliseconds from 1970-01-01T00:00:00Z
    `chronology` - the chronology, null means ISOChronology in default zone

### LocalDate

    public LocalDate(java.lang.Object instant)

  Constructs an instance from an Object that represents a datetime. The time zone will be retrieved from the object if possible, otherwise the default time zone will be used.

  If the object contains no chronology, `ISOChronology` is used. Once the constructor is completed, the zone is no longer used.

  The recognised object types are defined in `ConverterManager` and include ReadablePartial, ReadableInstant, String, Calendar and Date. The String formats are described by `ISODateTimeFormat.localDateParser()`. The default String converter ignores the zone and only parses the field values.

  Parameters:
    `instant` - the datetime object
  Throws:
    `java.lang.IllegalArgumentException` - if the instant is invalid

### LocalDate

    public LocalDate(java.lang.Object instant,
                     DateTimeZone zone)

  Constructs an instance from an Object that represents a datetime, forcing the time zone to that specified.

  If the object contains no chronology, `ISOChronology` is used. If the specified time zone is null, the default zone is used. Once the constructor is completed, the zone is no longer used.

  The recognised object types are defined in `ConverterManager` and include ReadablePartial, ReadableInstant, String, Calendar and Date. The String formats are described by `ISODateTimeFormat.localDateParser()`. The default String converter ignores the zone and only parses the field values.

  Parameters:
    `instant` - the datetime object
    `zone` - the time zone
  Throws:
    `java.lang.IllegalArgumentException` - if the instant is invalid

### LocalDate

    public LocalDate(java.lang.Object instant,
                     Chronology chronology)

  Constructs an instance from an Object that represents a datetime, using the specified chronology.

  If the chronology is null, ISO in the default time zone is used. Once the constructor is completed, the zone is no longer used.

  The recognised object types are defined in `ConverterManager` and include ReadablePartial, ReadableInstant, String, Calendar and Date. The String formats are described by `ISODateTimeFormat.localDateParser()`. The default String converter ignores the zone and only parses the field values.

  Parameters:
    `instant` - the datetime object
    `chronology` - the chronology
  Throws:
    `java.lang.IllegalArgumentException` - if the instant is invalid

### LocalDate

    public LocalDate(int year,
                     int monthOfYear,
                     int dayOfMonth)

  Constructs an instance set to the specified date and time using `ISOChronology`.

  Parameters:
    `year` - the year
    `monthOfYear` - the month of the year
    `dayOfMonth` - the day of the month

### LocalDate

    public LocalDate(int year,
                     int monthOfYear,
                     int dayOfMonth,
                     Chronology chronology)

  Constructs an instance set to the specified date and time using the specified chronology, whose zone is ignored.

  If the chronology is null, `ISOChronology` is used.

  Parameters:
    `year` - the year
    `monthOfYear` - the month of the year
    `dayOfMonth` - the day of the month
    `chronology` - the chronology, null means ISOChronology in default zone

Method Detail

### fromCalendarFields

    public static LocalDate fromCalendarFields(java.util.Calendar calendar)

  Constructs a LocalDate from a `java.util.Calendar` using exactly the same field values avoiding any time zone effects.

  Each field is queried from the Calendar and assigned to the LocalDate. This is useful if you have been using the Calendar as a local date, ignoing the zone.

  This factory method ignores the type of the calendar and always creates a LocalDate with ISO chronology. It is expected that you will only pass in instances of `GregorianCalendar` however this is not validated.

  Parameters:
    `calendar` - the Calendar to extract fields from
  Returns:
    the created LocalDate
  Throws:
    `java.lang.IllegalArgumentException` - if the calendar is null
    `java.lang.IllegalArgumentException` - if the date is invalid for the ISO chronology

### fromDateFields

    public static LocalDate fromDateFields(java.util.Date date)

  Constructs a LocalDate from a `java.util.Date` using exactly the same field values avoiding any time zone effects.

  Each field is queried from the Date and assigned to the LocalDate. This is useful if you have been using the Date as a local date, ignoing the zone.

  This factory method always creates a LocalDate with ISO chronology.

  Parameters:
    `date` - the Date to extract fields from
  Returns:
    the created LocalDate
  Throws:
    `java.lang.IllegalArgumentException` - if the calendar is null
    `java.lang.IllegalArgumentException` - if the date is invalid for the ISO chronology

### size

    public int size()

  Gets the number of fields in this partial, which is three. The supported fields are Year, MonthOfYear and DayOfMonth. Note that all fields from day and above may in fact be queried via other methods.

  Specified by:
    `size` in interface `ReadablePartial`
  Returns:
    the field count, three

### getField

    protected DateTimeField getField(int index,
                                     Chronology chrono)

  Gets the field for a specific index in the chronology specified.

  This method must not use any instance variables.

  Specified by:
    `getField` in class `AbstractPartial`
  Parameters:
    `index` - the index to retrieve
    `chrono` - the chronology to use
  Returns:
    the field

### getValue

    public int getValue(int index)

  Gets the value of the field at the specifed index.

  This method is required to support the `ReadablePartial` interface. The supported fields are Year, MonthOfYear and DayOfMonth. Note that all fields from day and above may in fact be queried via other methods.

  Specified by:
    `getValue` in interface `ReadablePartial`
  Parameters:
    `index` - the index, zero to two
  Returns:
    the value
  Throws:
    `java.lang.IndexOutOfBoundsException` - if the index is invalid

### get

    public int get(DateTimeFieldType fieldType)

  Get the value of one of the fields of a datetime.

  This method gets the value of the specified field. For example:

       LocalDate dt = LocalDate.nowDefaultZone();
       int year = dt.get(DateTimeFieldType.year());

  Specified by:
    `get` in interface `ReadablePartial`
  Overrides:
    `get` in class `AbstractPartial`
  Parameters:
    `fieldType` - a field type, usually obtained from DateTimeFieldType, not null
  Returns:
    the value of that field
  Throws:
    `java.lang.IllegalArgumentException` - if the field type is null or unsupported

### isSupported

    public boolean isSupported(DateTimeFieldType type)

  Checks if the field type specified is supported by this local date and chronology. This can be used to avoid exceptions in `get(DateTimeFieldType)`.

  Specified by:
    `isSupported` in interface `ReadablePartial`
  Overrides:
    `isSupported` in class `AbstractPartial`
  Parameters:
    `type` - a field type, usually obtained from DateTimeFieldType
  Returns:
    true if the field type is supported

### isSupported

    public boolean isSupported(DurationFieldType type)

  Checks if the duration type specified is supported by this local date and chronology.

  Parameters:
    `type` - a duration type, usually obtained from DurationFieldType
  Returns:
    true if the field type is supported

### getLocalMillis

    protected long getLocalMillis()

  Gets the local milliseconds from the Java epoch of 1970-01-01T00:00:00 (not fixed to any specific time zone).

  Specified by:
    `getLocalMillis` in class `BaseLocal`
  Returns:
    the number of milliseconds since 1970-01-01T00:00:00
  Since:
    1.5 (previously private)

### getChronology

    public Chronology getChronology()

  Gets the chronology of the date.

  Specified by:
    `getChronology` in interface `ReadablePartial`
  Returns:
    the Chronology that the date is using

### equals

    public boolean equals(java.lang.Object partial)

  Compares this ReadablePartial with another returning true if the chronology, field types and values are equal.

  Specified by:
    `equals` in interface `ReadablePartial`
  Overrides:
    `equals` in class `AbstractPartial`
  Parameters:
    `partial` - an object to check against
  Returns:
    true if fields and values are equal

### compareTo

    public int compareTo(java.lang.Object partial)

  Compares this partial with another returning an integer indicating the order.

  The fields are compared in order, from largest to smallest. The first field that is non-equal is used to determine the result.

  The specified object must be a partial instance whose field types match those of this partial.

  NOTE: This implementation violates the Comparable contract. This method will accept any instance of ReadablePartial as input. However, it is possible that some implementations of ReadablePartial exist that do not extend AbstractPartial, and thus will throw a ClassCastException if compared in the opposite direction. The cause of this problem is that ReadablePartial doesn't define the compareTo() method, however we can't change that until v2.0.

  Specified by:
    `compareTo` in interface `java.lang.Comparable`
  Overrides:
    `compareTo` in class `AbstractPartial`
  Parameters:
    `partial` - an object to check against
  Returns:
    negative if this is less, zero if equal, positive if greater
  Throws:
    `java.lang.ClassCastException` - if the partial is the wrong class or if it has field types that don't match
    `java.lang.NullPointerException` - if the partial is null

### toDateTimeAtStartOfDay

    public DateTime toDateTimeAtStartOfDay()

  Converts this LocalDate to a full datetime at the earliest valid time for the date using the default time zone.

  The time will normally be midnight, as that is the earliest time on any given day. However, in some time zones when Daylight Savings Time starts, there is no midnight because time jumps from 11:59 to 01:00. This method handles that situation by returning 01:00 on that date.

  This instance is immutable and unaffected by this method call.

  Returns:
    this date as a datetime at the start of the day
  Since:
    1.5

### toDateTimeAtStartOfDay

    public DateTime toDateTimeAtStartOfDay(DateTimeZone zone)

  Converts this LocalDate to a full datetime at the earliest valid time for the date using the specified time zone.

  The time will normally be midnight, as that is the earliest time on any given day. However, in some time zones when Daylight Savings Time starts, there is no midnight because time jumps from 11:59 to 01:00. This method handles that situation by returning 01:00 on that date.

  This method uses the chronology from this instance plus the time zone specified.

  This instance is immutable and unaffected by this method call.

  Parameters:
    `zone` - the zone to use, null means default zone
  Returns:
    this date as a datetime at the start of the day
  Since:
    1.5

### toDateTimeAtMidnight

    public DateTime toDateTimeAtMidnight()

  Deprecated. Use `toDateTimeAtStartOfDay()` which won't throw an exception

  Converts this LocalDate to a full datetime at midnight using the default time zone.

  This method will throw an exception if the default time zone switches to Daylight Savings Time at midnight and this LocalDate represents that switchover date. The problem is that there is no such time as midnight on the required date, and as such an exception is thrown.

  This instance is immutable and unaffected by this method call.

  Returns:
    this date as a datetime at midnight

### toDateTimeAtMidnight

    public DateTime toDateTimeAtMidnight(DateTimeZone zone)

  Deprecated. Use `toDateTimeAtStartOfDay(DateTimeZone)` which won't throw an exception

  Converts this LocalDate to a full datetime at midnight using the specified time zone.

  This method will throw an exception if the time zone switches to Daylight Savings Time at midnight and this LocalDate represents that switchover date. The problem is that there is no such time as midnight on the required date, and as such an exception is thrown.

  This method uses the chronology from this instance plus the time zone specified.

  This instance is immutable and unaffected by this method call.

  Parameters:
    `zone` - the zone to use, null means default zone
  Returns:
    this date as a datetime at midnight

### toDateTimeAtCurrentTime

    public DateTime toDateTimeAtCurrentTime()

  Converts this LocalDate to a full datetime using the default time zone setting the date fields from this instance and the time fields from the current time.

  This method will throw an exception if the datetime that would be created does not exist when the time zone is taken into account.

  This instance is immutable and unaffected by this method call.

  Returns:
    this date as a datetime with the time as the current time

### toDateTimeAtCurrentTime

    public DateTime toDateTimeAtCurrentTime(DateTimeZone zone)

  Converts this LocalDate to a full datetime using the specified time zone setting the date fields from this instance and the time fields from the current time.

  This method uses the chronology from this instance plus the time zone specified.

  This method will throw an exception if the datetime that would be created does not exist when the time zone is taken into account.

  This instance is immutable and unaffected by this method call.

  Parameters:
    `zone` - the zone to use, null means default zone
  Returns:
    this date as a datetime with the time as the current time

### toDateMidnight

    public DateMidnight toDateMidnight()

  Converts this LocalDate to a DateMidnight in the default time zone.

  As from v1.5, you are recommended to avoid DateMidnight and use `toDateTimeAtStartOfDay()` instead because of the exception detailed below.

  This method will throw an exception if the default time zone switches to Daylight Savings Time at midnight and this LocalDate represents that switchover date. The problem is that there is no such time as midnight on the required date, and as such an exception is thrown.

  This instance is immutable and unaffected by this method call.

  Returns:
    the DateMidnight instance in the default zone

### toDateMidnight

    public DateMidnight toDateMidnight(DateTimeZone zone)

  Converts this LocalDate to a DateMidnight.

  As from v1.5, you are recommended to avoid DateMidnight and use `toDateTimeAtStartOfDay()` instead because of the exception detailed below.

  This method will throw an exception if the time zone switches to Daylight Savings Time at midnight and this LocalDate represents that switchover date. The problem is that there is no such time as midnight on the required date, and as such an exception is thrown.

  This instance is immutable and unaffected by this method call.

  Parameters:
    `zone` - the zone to get the DateMidnight in, null means default zone
  Returns:
    the DateMidnight instance

### toLocalDateTime

    public LocalDateTime toLocalDateTime(LocalTime time)

  Converts this object to a LocalDateTime using a LocalTime to fill in the missing fields.

  The resulting chronology is determined by the chronology of this LocalDate. The chronology of the time must also match. If the time is null an exception is thrown.

  This instance is immutable and unaffected by this method call.

  Parameters:
    `time` - the time of day to use, must not be null
  Returns:
    the LocalDateTime instance
  Throws:
    `java.lang.IllegalArgumentException` - if the time is null
    `java.lang.IllegalArgumentException` - if the chronology of the time does not match
  Since:
    1.5

### toDateTime

    public DateTime toDateTime(LocalTime time)

  Converts this object to a DateTime using a LocalTime to fill in the missing fields and using the default time zone.

  The resulting chronology is determined by the chronology of this LocalDate. The chronology of the time must match. If the time is null, the current time in the date's chronology is used.

  This method will throw an exception if the datetime that would be created does not exist when the time zone is taken into account.

  This instance is immutable and unaffected by this method call.

  Parameters:
    `time` - the time of day to use, null means current time
  Returns:
    the DateTime instance
  Throws:
    `java.lang.IllegalArgumentException` - if the chronology of the time does not match

### toDateTime

    public DateTime toDateTime(LocalTime time,
                               DateTimeZone zone)

  Converts this object to a DateTime using a LocalTime to fill in the missing fields.

  The resulting chronology is determined by the chronology of this LocalDate plus the time zone. The chronology of the time must match. If the time is null, the current time in the date's chronology is used.

  This method will throw an exception if the datetime that would be created does not exist when the time zone is taken into account.

  This instance is immutable and unaffected by this method call.

  Parameters:
    `time` - the time of day to use, null means current time
    `zone` - the zone to get the DateTime in, null means default
  Returns:
    the DateTime instance
  Throws:
    `java.lang.IllegalArgumentException` - if the chronology of the time does not match

### toInterval

    public Interval toInterval()

  Converts this object to an Interval representing the whole day in the default time zone.

  This instance is immutable and unaffected by this method call.

  Returns:
    a interval over the day

### toInterval

    public Interval toInterval(DateTimeZone zone)

  Converts this object to an Interval representing the whole day.

  This instance is immutable and unaffected by this method call.

  Parameters:
    `zone` - the zone to get the Interval in, null means default
  Returns:
    a interval over the day

### withFields

    public LocalDate withFields(ReadablePartial partial)

  Returns a copy of this date with the partial set of fields replacing those from this instance.

  For example, if the partial contains a year and a month then those two fields will be changed in the returned instance. Unsupported fields are ignored. If the partial is null, then `this` is returned.

  Parameters:
    `partial` - the partial set of fields to apply to this date, null ignored
  Returns:
    a copy of this date with a different set of fields
  Throws:
    `java.lang.IllegalArgumentException` - if any value is invalid

### withField

    public LocalDate withField(DateTimeFieldType fieldType,
                               int value)

  Returns a copy of this date with the specified field set to a new value.

  For example, if the field type is `monthOfYear` then the month of year field will be changed in the returned instance. If the field type is null, then `this` is returned.

  These two lines are equivalent:

       LocalDate updated = dt.withDayOfMonth(6);
       LocalDate updated = dt.withField(DateTimeFieldType.dayOfMonth(), 6);

  Parameters:
    `fieldType` - the field type to set, not null
    `value` - the value to set
  Returns:
    a copy of this date with the field set
  Throws:
    `java.lang.IllegalArgumentException` - if the field is null or unsupported

### withFieldAdded

    public LocalDate withFieldAdded(DurationFieldType fieldType,
                                    int amount)

  Returns a copy of this date with the value of the specified field increased.

  If the addition is zero or the field is null, then `this` is returned.

  These three lines are equivalent:

       LocalDate added = dt.withFieldAdded(DurationFieldType.years(), 6);
       LocalDate added = dt.plusYears(6);
       LocalDate added = dt.plus(Period.years(6));

  Parameters:
    `fieldType` - the field type to add to, not null
    `amount` - the amount to add
  Returns:
    a copy of this date with the field updated
  Throws:
    `java.lang.IllegalArgumentException` - if the field is null or unsupported
    `java.lang.ArithmeticException` - if the result exceeds the internal capacity

### withPeriodAdded

    public LocalDate withPeriodAdded(ReadablePeriod period,
                                     int scalar)

  Returns a copy of this date with the specified period added.

  If the addition is zero, then `this` is returned.

  This method is typically used to add multiple copies of complex period instances. Adding one field is best achieved using methods like `withFieldAdded(DurationFieldType, int)` or `plusYears(int)`.

  Unsupported time fields are ignored, thus adding a period of 24 hours will not have any effect.

  Parameters:
    `period` - the period to add to this one, null means zero
    `scalar` - the amount of times to add, such as -1 to subtract once
  Returns:
    a copy of this date with the period added
  Throws:
    `java.lang.ArithmeticException` - if the result exceeds the internal capacity

### plus

    public LocalDate plus(ReadablePeriod period)

  Returns a copy of this date with the specified period added.

  If the amount is zero or null, then `this` is returned.

  This method is typically used to add complex period instances. Adding one field is best achieved using methods like `plusYears(int)`.

  Unsupported time fields are ignored, thus adding a period of 24 hours will not have any effect.

  Parameters:
    `period` - the period to add to this one, null means zero
  Returns:
    a copy of this date with the period added
  Throws:
    `java.lang.ArithmeticException` - if the result exceeds the internal capacity

### plusYears

    public LocalDate plusYears(int years)

  Returns a copy of this date plus the specified number of years.

  This LocalDate instance is immutable and unaffected by this method call.

  The following three lines are identical in effect:

       LocalDate added = dt.plusYears(6);
       LocalDate added = dt.plus(Period.years(6));
       LocalDate added = dt.withFieldAdded(DurationFieldType.years(), 6);

  Parameters:
    `years` - the amount of years to add, may be negative
  Returns:
    the new LocalDate plus the increased years

### plusMonths

    public LocalDate plusMonths(int months)

  Returns a copy of this date plus the specified number of months.

  This LocalDate instance is immutable and unaffected by this method call.

  The following three lines are identical in effect:

       LocalDate added = dt.plusMonths(6);
       LocalDate added = dt.plus(Period.months(6));
       LocalDate added = dt.withFieldAdded(DurationFieldType.months(), 6);

  Parameters:
    `months` - the amount of months to add, may be negative
  Returns:
    the new LocalDate plus the increased months

### plusWeeks

    public LocalDate plusWeeks(int weeks)

  Returns a copy of this date plus the specified number of weeks.

  This LocalDate instance is immutable and unaffected by this method call.

  The following three lines are identical in effect:

       LocalDate added = dt.plusWeeks(6);
       LocalDate added = dt.plus(Period.weeks(6));
       LocalDate added = dt.withFieldAdded(DurationFieldType.weeks(), 6);

  Parameters:
    `weeks` - the amount of weeks to add, may be negative
  Returns:
    the new LocalDate plus the increased weeks

### plusDays

    public LocalDate plusDays(int days)

  Returns a copy of this date plus the specified number of days.

  This LocalDate instance is immutable and unaffected by this method call.

  The following three lines are identical in effect:

       LocalDate added = dt.plusDays(6);
       LocalDate added = dt.plus(Period.days(6));
       LocalDate added = dt.withFieldAdded(DurationFieldType.days(), 6);

  Parameters:
    `days` - the amount of days to add, may be negative
  Returns:
    the new LocalDate plus the increased days

### minus

    public LocalDate minus(ReadablePeriod period)

  Returns a copy of this date with the specified period taken away.

  If the amount is zero or null, then `this` is returned.

  This method is typically used to subtract complex period instances. Subtracting one field is best achieved using methods like `minusYears(int)`.

  Unsupported time fields are ignored, thus subtracting a period of 24 hours will not have any effect.

  Parameters:
    `period` - the period to reduce this instant by
  Returns:
    a copy of this LocalDate with the period taken away
  Throws:
    `java.lang.ArithmeticException` - if the result exceeds the internal capacity

### minusYears

    public LocalDate minusYears(int years)

  Returns a copy of this date minus the specified number of years.

  This LocalDate instance is immutable and unaffected by this method call.

  The following three lines are identical in effect:

       LocalDate subtracted = dt.minusYears(6);
       LocalDate subtracted = dt.minus(Period.years(6));
       LocalDate subtracted = dt.withFieldAdded(DurationFieldType.years(), -6);

  Parameters:
    `years` - the amount of years to subtract, may be negative
  Returns:
    the new LocalDate minus the increased years

### minusMonths

    public LocalDate minusMonths(int months)

  Returns a copy of this date minus the specified number of months.

  This LocalDate instance is immutable and unaffected by this method call.

  The following three lines are identical in effect:

       LocalDate subtracted = dt.minusMonths(6);
       LocalDate subtracted = dt.minus(Period.months(6));
       LocalDate subtracted = dt.withFieldAdded(DurationFieldType.months(), -6);

  Parameters:
    `months` - the amount of months to subtract, may be negative
  Returns:
    the new LocalDate minus the increased months

### minusWeeks

    public LocalDate minusWeeks(int weeks)

  Returns a copy of this date minus the specified number of weeks.

  This LocalDate instance is immutable and unaffected by this method call.

  The following three lines are identical in effect:

       LocalDate subtracted = dt.minusWeeks(6);
       LocalDate subtracted = dt.minus(Period.weeks(6));
       LocalDate subtracted = dt.withFieldAdded(DurationFieldType.weeks(), -6);

  Parameters:
    `weeks` - the amount of weeks to subtract, may be negative
  Returns:
    the new LocalDate minus the increased weeks

### minusDays

    public LocalDate minusDays(int days)

  Returns a copy of this date minus the specified number of days.

  This LocalDate instance is immutable and unaffected by this method call.

  The following three lines are identical in effect:

       LocalDate subtracted = dt.minusDays(6);
       LocalDate subtracted = dt.minus(Period.days(6));
       LocalDate subtracted = dt.withFieldAdded(DurationFieldType.days(), -6);

  Parameters:
    `days` - the amount of days to subtract, may be negative
  Returns:
    the new LocalDate minus the increased days

### property

    public LocalDate.Property property(DateTimeFieldType fieldType)

  Gets the property object for the specified type, which contains many useful methods.

  Parameters:
    `fieldType` - the field type to get the chronology for
  Returns:
    the property object
  Throws:
    `java.lang.IllegalArgumentException` - if the field is null or unsupported

### getEra

    public int getEra()

  Get the era field value.

  Returns:
    the era

### getCenturyOfEra

    public int getCenturyOfEra()

  Get the year of era field value.

  Returns:
    the year of era

### getYearOfEra

    public int getYearOfEra()

  Get the year of era field value.

  Returns:
    the year of era

### getYearOfCentury

    public int getYearOfCentury()

  Get the year of century field value.

  Returns:
    the year of century

### getYear

    public int getYear()

  Get the year field value.

  Returns:
    the year

### getWeekyear

    public int getWeekyear()

  Get the weekyear field value.

  The weekyear is the year that matches with the weekOfWeekyear field. In the standard ISO8601 week algorithm, the first week of the year is that in which at least 4 days are in the year. As a result of this definition, day 1 of the first week may be in the previous year. The weekyear allows you to query the effective year for that day.

  Returns:
    the weekyear

### getMonthOfYear

    public int getMonthOfYear()

  Get the month of year field value.

  Returns:
    the month of year

### getWeekOfWeekyear

    public int getWeekOfWeekyear()

  Get the week of weekyear field value.

  Returns:
    the week of a week based year

### getDayOfYear

    public int getDayOfYear()

  Get the day of year field value.

  Returns:
    the day of year

### getDayOfMonth

    public int getDayOfMonth()

  Get the day of month field value.

  The values for the day of month are defined in `DateTimeConstants`.

  Returns:
    the day of month

### getDayOfWeek

    public int getDayOfWeek()

  Get the day of week field value.

  The values for the day of week are defined in `DateTimeConstants`.

  Returns:
    the day of week

### withEra

    public LocalDate withEra(int era)

  Returns a copy of this date with the era field updated.

  LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of era changed.

  Parameters:
    `era` - the era to set
  Returns:
    a copy of this object with the field set
  Throws:
    `java.lang.IllegalArgumentException` - if the value is invalid

### withCenturyOfEra

    public LocalDate withCenturyOfEra(int centuryOfEra)

  Returns a copy of this date with the century of era field updated.

  LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of century of era changed.

  Parameters:
    `centuryOfEra` - the centurey of era to set
  Returns:
    a copy of this object with the field set
  Throws:
    `java.lang.IllegalArgumentException` - if the value is invalid

### withYearOfEra

    public LocalDate withYearOfEra(int yearOfEra)

  Returns a copy of this date with the year of era field updated.

  LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of year of era changed.

  Parameters:
    `yearOfEra` - the year of era to set
  Returns:
    a copy of this object with the field set
  Throws:
    `java.lang.IllegalArgumentException` - if the value is invalid

### withYearOfCentury

    public LocalDate withYearOfCentury(int yearOfCentury)

  Returns a copy of this date with the year of century field updated.

  LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of year of century changed.

  Parameters:
    `yearOfCentury` - the year of century to set
  Returns:
    a copy of this object with the field set
  Throws:
    `java.lang.IllegalArgumentException` - if the value is invalid

### withYear

    public LocalDate withYear(int year)

  Returns a copy of this date with the year field updated.

  LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of year changed.

  Parameters:
    `year` - the year to set
  Returns:
    a copy of this object with the field set
  Throws:
    `java.lang.IllegalArgumentException` - if the value is invalid

### withWeekyear

    public LocalDate withWeekyear(int weekyear)

  Returns a copy of this date with the weekyear field updated.

  LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of weekyear changed.

  Parameters:
    `weekyear` - the weekyear to set
  Returns:
    a copy of this object with the field set
  Throws:
    `java.lang.IllegalArgumentException` - if the value is invalid

### withMonthOfYear

    public LocalDate withMonthOfYear(int monthOfYear)

  Returns a copy of this date with the month of year field updated.

  LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of month of year changed.

  Parameters:
    `monthOfYear` - the month of year to set
  Returns:
    a copy of this object with the field set
  Throws:
    `java.lang.IllegalArgumentException` - if the value is invalid

### withWeekOfWeekyear

    public LocalDate withWeekOfWeekyear(int weekOfWeekyear)

  Returns a copy of this date with the week of weekyear field updated.

  LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of week of weekyear changed.

  Parameters:
    `weekOfWeekyear` - the week of weekyear to set
  Returns:
    a copy of this object with the field set
  Throws:
    `java.lang.IllegalArgumentException` - if the value is invalid

### withDayOfYear

    public LocalDate withDayOfYear(int dayOfYear)

  Returns a copy of this date with the day of year field updated.

  LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of day of year changed.

  Parameters:
    `dayOfYear` - the day of year to set
  Returns:
    a copy of this object with the field set
  Throws:
    `java.lang.IllegalArgumentException` - if the value is invalid

### withDayOfMonth

    public LocalDate withDayOfMonth(int dayOfMonth)

  Returns a copy of this date with the day of month field updated.

  LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of day of month changed.

  Parameters:
    `dayOfMonth` - the day of month to set
  Returns:
    a copy of this object with the field set
  Throws:
    `java.lang.IllegalArgumentException` - if the value is invalid

### withDayOfWeek

    public LocalDate withDayOfWeek(int dayOfWeek)

  Returns a copy of this date with the day of week field updated.

  LocalDate is immutable, so there are no set methods. Instead, this method returns a new instance with the value of day of week changed.

  Parameters:
    `dayOfWeek` - the day of week to set
  Returns:
    a copy of this object with the field set
  Throws:
    `java.lang.IllegalArgumentException` - if the value is invalid

### era

    public LocalDate.Property era()

  Get the era property which provides access to advanced functionality.

  Returns:
    the era property

### centuryOfEra

    public LocalDate.Property centuryOfEra()

  Get the century of era property which provides access to advanced functionality.

  Returns:
    the year of era property

### yearOfCentury

    public LocalDate.Property yearOfCentury()

  Get the year of century property which provides access to advanced functionality.

  Returns:
    the year of era property

### yearOfEra

    public LocalDate.Property yearOfEra()

  Get the year of era property which provides access to advanced functionality.

  Returns:
    the year of era property

### year

    public LocalDate.Property year()

  Get the year property which provides access to advanced functionality.

  Returns:
    the year property

### weekyear

    public LocalDate.Property weekyear()

  Get the weekyear property which provides access to advanced functionality.

  Returns:
    the weekyear property

### monthOfYear

    public LocalDate.Property monthOfYear()

  Get the month of year property which provides access to advanced functionality.

  Returns:
    the month of year property

### weekOfWeekyear

    public LocalDate.Property weekOfWeekyear()

  Get the week of a week based year property which provides access to advanced functionality.

  Returns:
    the week of a week based year property

### dayOfYear

    public LocalDate.Property dayOfYear()

  Get the day of year property which provides access to advanced functionality.

  Returns:
    the day of year property

### dayOfMonth

    public LocalDate.Property dayOfMonth()

  Get the day of month property which provides access to advanced functionality.

  Returns:
    the day of month property

### dayOfWeek

    public LocalDate.Property dayOfWeek()

  Get the day of week property which provides access to advanced functionality.

  Returns:
    the day of week property

### toString

    public java.lang.String toString()

  Output the date time in ISO8601 format (yyyy-MM-dd).

  Specified by:
    `toString` in interface `ReadablePartial`
  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    ISO8601 time formatted string.

### toString

    public java.lang.String toString(java.lang.String pattern)

  Output the date using the specified format pattern.

  Parameters:
    `pattern` - the pattern specification, null means use `toString`
  See Also:
    `DateTimeFormat`

### toString

    public java.lang.String toString(java.lang.String pattern,
                                     java.util.Locale locale)
                              throws java.lang.IllegalArgumentException

  Output the date using the specified format pattern.

  Parameters:
    `pattern` - the pattern specification, null means use `toString`
    `locale` - Locale to use, null means default
  Throws:
    `java.lang.IllegalArgumentException`
  See Also:
    `DateTimeFormat`

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