2007-12-03
.
LocalDate
is an immutable date-time object that represents a date,
often viewed as year-month-day. Other date fields, such as day-of-year,
day-of-week and week-of-year, can also be accessed.
For example, the value "2nd October 2007" can be stored in a LocalDate
.
This class does not store or represent a time or time-zone. Instead, it is a description of the date, as used for birthdays. It cannot represent an instant on the time-line without additional information such as an offset or time-zone.
The ISO-8601 calendar system is the modern civil calendar system used today in most of the world. It is equivalent to the proleptic Gregorian calendar system, in which today's rules for leap years are applied for all time. For most applications written today, the ISO-8601 rules are entirely suitable. However, any application that makes use of historical dates, and requires them to be accurate will find the ISO-8601 approach unsuitable.
This is a value-based
class; programmers should treat instances that are
equal as interchangeable and should not
use instances for synchronization, or unpredictable behavior may
occur. For example, in a future release, synchronization may fail.
The equals
method should be used for comparisons.
Implementation Specification
This class is immutable and thread-safe.
Modifier and Type | Field and Description |
---|---|
private final short | day
The day-of-month. |
pack-priv static final long | DAYS_0000_TO_1970
The number of days from year zero to year 1970. |
private static final int | DAYS_PER_CYCLE
The number of days in a 400 year cycle. |
public static final LocalDate | EPOCH
The epoch year |
public static final LocalDate | MAX
The maximum supported |
public static final LocalDate | MIN
The minimum supported |
private final short | month
The month-of-year. |
private static final long | serialVersionUID
Serialization version. |
private final int | year
The year. |
Access | Constructor and Description |
---|---|
private | LocalDate(int
the year to represent, from MIN_YEAR to MAX_YEAR year, int the month-of-year to represent, not null month, int the day-of-month to represent, valid for year-month, from 1 to 31 dayOfMonth)Constructor, previously validated. |
Modifier and Type | Method and Description |
---|---|
public Temporal | Returns: the adjusted object, not nullthe target object to be adjusted, not null temporal)Overrides default java. Implements java. Adjusts the specified temporal object to have the same date as this object. |
public LocalDateTime | Returns: the local date-time of midnight at the start of this date, not nullCombines this date with the time of midnight to create a |
public ZonedDateTime | Returns: the zoned date-time formed from this date and the earliest valid time for the zone, not nullthe zone ID to use, not null zone)Returns a zoned date-time from this date at the earliest valid time according to the rules in the time-zone. |
public LocalDateTime | Returns: the local date-time formed from this date and the specified time, not nullthe time to combine with, not null time)Overrides default java. Combines this date with a time to create a |
public LocalDateTime | Returns: the local date-time formed from this date and the specified time, not nullthe hour-of-day to use, from 0 to 23 hour, int the minute-of-hour to use, from 0 to 59 minute)Combines this date with a time to create a |
public LocalDateTime | Returns: the local date-time formed from this date and the specified time, not nullthe hour-of-day to use, from 0 to 23 hour, int the minute-of-hour to use, from 0 to 59 minute, int the second-of-minute to represent, from 0 to 59 second)Combines this date with a time to create a |
public LocalDateTime | Returns: the local date-time formed from this date and the specified time, not nullthe hour-of-day to use, from 0 to 23 hour, int the minute-of-hour to use, from 0 to 59 minute, int the second-of-minute to represent, from 0 to 59 second, int the nano-of-second to represent, from 0 to 999,999,999 nanoOfSecond)Combines this date with a time to create a |
public OffsetDateTime | Returns: the offset date-time formed from this date and the specified time, not nullthe time to combine with, not null time)Combines this date with an offset time to create an |
public int | Returns: the comparator value, that is the comparison of this local date with theother local date and this chronology with the other chronology,
in order, returning the first non-zero result, and otherwise returning zerothe other date to compare to, not null other)Overrides default java. Compares this date to another date. |
pack-priv int | |
private static LocalDate | Returns: the local date, not nullthe year to represent, validated from MIN_YEAR to MAX_YEAR year, int the month-of-year to represent, from 1 to 12, validated month, int the day-of-month to represent, validated from 1 to 31 dayOfMonth)Creates a local date from the year, month and day fields. |
public Stream | Returns: a sequentialStream for the range of LocalDate valuesthe end date, exclusive, not null endExclusive)Returns a sequential ordered stream of dates. |
public Stream | Returns: a sequentialStream for the range of LocalDate valuesthe end date, exclusive, not null endExclusive, Period the non-zero, non-negative step)Period which represents the step.Returns a sequential ordered stream of dates by given incremental step. |
pack-priv long | |
public boolean | Returns: true if this is equal to the other datethe object to check, null returns false obj)Overrides java. Implements java. Checks if this date is equal to another date. |
public String | Returns: the formatted date string, not nullthe formatter to use, not null formatter)Overrides default java. Formats this date using the specified formatter. |
public static LocalDate | Returns: the local date, not nullthe temporal object to convert, not null temporal)Hides java. Obtains an instance of |
public int | Returns: the value for the fieldthe field to get, not null field)Overrides default java. Gets the value of the specified field from this date as an |
private int | |
public IsoChronology | Returns: the ISO chronology, not nullImplements java. Gets the chronology of this date, which is the ISO calendar system. |
public int | |
public DayOfWeek | Returns: the day-of-week, not nullGets the day-of-week field, which is an enum |
public int | Returns: the day-of-year, from 1 to 365, or 366 in a leap yearGets the day-of-year field. |
public IsoEra | Returns: the IsoEra applicable at this date, not nullOverrides default java. Gets the era applicable at this date. |
public long | Returns: the value for the fieldthe field to get, not null field)Implements java. Gets the value of the specified field from this date as a |
public Month | |
public int | |
private long | |
public int | |
public int | Returns: a suitable hash codeOverrides java. Implements java. A hash code for this date. |
public boolean | Returns: true if this date is after the specified datethe other date to compare to, not null other)Overrides default java. Checks if this date is after the specified date. |
public boolean | Returns: true if this date is before the specified datethe other date to compare to, not null other)Overrides default java. Checks if this date is before the specified date. |
public boolean | Returns: true if this date is equal to the specified datethe other date to compare to, not null other)Overrides default java. Checks if this date is equal to the specified date. |
public boolean | Returns: true if the year is leap, false otherwiseOverrides default java. Checks if the year is a leap year, according to the ISO proleptic calendar system rules. |
public boolean | Returns: true if the field is supported on this date, false if notthe field to check, null returns false field)Overrides default java. Implements java. Checks if the specified field is supported. |
public boolean | Returns: true if the unit can be added/subtracted, false if notthe unit to check, null returns false unit)Overrides default java. Implements java. Checks if the specified unit is supported. |
public int | Returns: the length of the month in daysImplements java. Returns the length of the month represented by this date. |
public int | Returns: 366 if the year is leap, 365 otherwiseOverrides default java. Returns the length of the year represented by this date. |
public LocalDate | Returns: aLocalDate based on this date with the subtraction made, not nullthe amount to subtract, not null amountToSubtract)Overrides default java. Returns a copy of this date with the specified amount subtracted. |
public LocalDate | Returns: aLocalDate based on this date with the specified amount subtracted, not nullthe amount of the unit to subtract from the result, may be negative amountToSubtract, TemporalUnit the unit of the amount to subtract, not null unit)Overrides default java. Returns a copy of this date with the specified amount subtracted. |
public LocalDate | Returns: aLocalDate based on this date with the days subtracted, not nullthe days to subtract, may be negative daysToSubtract)Returns a copy of this |
public LocalDate | Returns: aLocalDate based on this date with the months subtracted, not nullthe months to subtract, may be negative monthsToSubtract)Returns a copy of this |
public LocalDate | Returns: aLocalDate based on this date with the weeks subtracted, not nullthe weeks to subtract, may be negative weeksToSubtract)Returns a copy of this |
public LocalDate | Returns: aLocalDate based on this date with the years subtracted, not nullthe years to subtract, may be negative yearsToSubtract)Returns a copy of this |
private long | |
public static LocalDate | Returns: the current date using the system clock and default time-zone, not nullObtains the current date from the system clock in the default time-zone. |
public static LocalDate | |
public static LocalDate | |
public static LocalDate | |
public static LocalDate | Returns: the local date, not nullthe year to represent, from MIN_YEAR to MAX_YEAR year, int the month-of-year to represent, from 1 (January) to 12 (December) month, int the day-of-month to represent, from 1 to 31 dayOfMonth)Obtains an instance of |
public static LocalDate | Returns: the local date, not nullthe Epoch Day to convert, based on the epoch 1970-01-01 epochDay)Obtains an instance of |
public static LocalDate | |
public static LocalDate | Returns: the local date, not nullthe year to represent, from MIN_YEAR to MAX_YEAR year, int the day-of-year to represent, from 1 to 366 dayOfYear)Obtains an instance of |
public static LocalDate | Returns: the parsed local date, not nullthe text to parse such as "2007-12-03", not null text)Obtains an instance of |
public static LocalDate | Returns: the parsed local date, not nullthe text to parse, not null text, DateTimeFormatter the formatter to use, not null formatter)Obtains an instance of |
public LocalDate | Returns: aLocalDate based on this date with the addition made, not nullthe amount to add, not null amountToAdd)Overrides default java. Returns a copy of this date with the specified amount added. |
public LocalDate | Returns: aLocalDate based on this date with the specified amount added, not nullthe amount of the unit to add to the result, may be negative amountToAdd, TemporalUnit the unit of the amount to add, not null unit)Overrides default java. Implements java. Returns a copy of this date with the specified amount added. |
public LocalDate | Returns: aLocalDate based on this date with the days added, not nullthe days to add, may be negative daysToAdd)Returns a copy of this |
public LocalDate | Returns: aLocalDate based on this date with the months added, not nullthe months to add, may be negative monthsToAdd)Returns a copy of this |
public LocalDate | Returns: aLocalDate based on this date with the weeks added, not nullthe weeks to add, may be negative weeksToAdd)Returns a copy of this |
public LocalDate | Returns: aLocalDate based on this date with the years added, not nullthe years to add, may be negative yearsToAdd)Returns a copy of this |
public < the type of the result R> R | Returns: the query result, null may be returned (defined by the query)the query to invoke, not null query)Overrides default java. Queries this date using the specified query. |
public ValueRange | Returns: the range of valid values for the field, not nullthe field to query the range for, not null field)Overrides default java. Gets the range of valid values for the specified field. |
pack-priv static LocalDate | |
private void | |
private static LocalDate | Returns: the resolved date, not nullthe year to represent, validated from MIN_YEAR to MAX_YEAR year, int the month-of-year to represent, validated from 1 to 12 month, int the day-of-month to represent, validated from 1 to 31 day)Resolves the date, resolving days past the end of month. |
public long | toEpochDay()
Overrides default java. Converts this date to the Epoch Day. |
public long | Returns: the number of seconds since the epoch of 1970-01-01T00:00:00Z, may be negativethe local time, not null time, ZoneOffset the zone offset, not null offset)Converts this |
public String | Returns: a string representation of this date, not nullOverrides java. Implements java. Outputs this date as a |
public long | Returns: the amount of time between this date and the end datethe end date, exclusive, which is converted to a endExclusive, TemporalUnit LocalDate , not nullthe unit to measure the amount in, not null unit)Implements java. Calculates the amount of time until another date in terms of the specified unit. |
public Period | Returns: the period between this date and the end date, not nullthe end date, exclusive, which may be in any chronology, not null endDateExclusive)Implements java. Calculates the period between this date and another date as a |
public LocalDate | Returns: aLocalDate based on this with the adjustment made, not nullthe adjuster to use, not null adjuster)Overrides default java. Returns an adjusted copy of this date. |
public LocalDate | Returns: aLocalDate based on this with the specified field set, not nullthe field to set in the result, not null field, long the new value of the field in the result newValue)Overrides default java. Implements java. Returns a copy of this date with the specified field set to a new value. |
public LocalDate | Returns: aLocalDate based on this date with the requested day, not nullthe day-of-month to set in the result, from 1 to 28-31 dayOfMonth)Returns a copy of this |
public LocalDate | Returns: aLocalDate based on this date with the requested day, not nullthe day-of-year to set in the result, from 1 to 365-366 dayOfYear)Returns a copy of this |
public LocalDate | Returns: aLocalDate based on this date with the requested month, not nullthe month-of-year to set in the result, from 1 (January) to 12 (December) month)Returns a copy of this |
public LocalDate | Returns: aLocalDate based on this date with the requested year, not nullthe year to set in the result, from MIN_YEAR to MAX_YEAR year)Returns a copy of this |
pack-priv void | |
private Object | Returns: the instance ofSer , not nullWrites the object using a dedicated serialized form. |