2007-12-03T10:15:30
.
LocalDateTime
is an immutable date-time object that represents a date-time,
often viewed as year-month-day-hour-minute-second. Other date and time fields,
such as day-of-year, day-of-week and week-of-year, can also be accessed.
Time is represented to nanosecond precision.
For example, the value "2nd October 2007 at 13:45.30.123456789" can be
stored in a LocalDateTime
.
This class does not store or represent a time-zone. Instead, it is a description of the date, as used for birthdays, combined with the local time as seen on a wall clock. 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 LocalDate | date
The date part. |
public static final LocalDateTime | MAX
The maximum supported |
public static final LocalDateTime | MIN
The minimum supported |
private static final long | serialVersionUID
Serialization version. |
private final LocalTime | time
The time part. |
Access | Constructor and Description |
---|---|
private | LocalDateTime(LocalDate
the date part of the date-time, validated not null date, LocalTime the time part of the date-time, validated not null time)Constructor. |
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. |
public OffsetDateTime | Returns: the offset date-time formed from this date-time and the specified offset, not nullthe offset to combine with, not null offset)Combines this date-time with an offset to create an |
public ZonedDateTime | Returns: the zoned date-time formed from this date-time, not nullthe time-zone to use, not null zone)Implements java. ZonedDateTime .
|
public int | Returns: the comparator value, that is the comparison of this local date-time with theother local date-time and this chronology with the other chronology,
in order, returning the first non-zero result, and otherwise returning zerothe other date-time to compare to, not null other)Overrides default java. |
private int | |
public boolean | Returns: true if this is equal to the other date-timethe object to check, null returns false obj)Overrides java. Implements java. |
public String | Returns: the formatted date-time string, not nullthe formatter to use, not null formatter)Overrides default java. |
public static LocalDateTime | Returns: the local date-time, not nullthe temporal object to convert, not null temporal)Hides java. LocalDateTime from a temporal object.
|
public int | Returns: the value for the fieldthe field to get, not null field)Overrides default java. int .
|
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 int | |
public long | Returns: the value for the fieldthe field to get, not null field)Implements java. long .
|
public int | |
public Month | |
public int | |
public int | |
public int | |
public int | |
public int | Returns: a suitable hash codeOverrides java. Implements java. |
public boolean | Returns: true if this date-time is after the specified date-timethe other date-time to compare to, not null other)Overrides default java. |
public boolean | Returns: true if this date-time is before the specified date-timethe other date-time to compare to, not null other)Overrides default java. |
public boolean | Returns: true if this date-time is equal to the specified date-timethe other date-time to compare to, not null other)Overrides default java. |
public boolean | Returns: true if the field is supported on this date-time, false if notthe field to check, null returns false field)Implements java. |
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. |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the subtraction made, not nullthe amount to subtract, not null amountToSubtract)Overrides default java. |
public LocalDateTime | Returns: aLocalDateTime based on this date-time 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. |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the days subtracted, not nullthe days to subtract, may be negative days)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the hours subtracted, not nullthe hours to subtract, may be negative hours)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the minutes subtracted, not nullthe minutes to subtract, may be negative minutes)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the months subtracted, not nullthe months to subtract, may be negative months)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the nanoseconds subtracted, not nullthe nanos to subtract, may be negative nanos)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the seconds subtracted, not nullthe seconds to subtract, may be negative seconds)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the weeks subtracted, not nullthe weeks to subtract, may be negative weeks)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the years subtracted, not nullthe years to subtract, may be negative years)Returns a copy of this |
public static LocalDateTime | Returns: the current date-time using the system clock and default time-zone, not nullObtains the current date-time from the system clock in the default time-zone. |
public static LocalDateTime | |
public static LocalDateTime | |
public static LocalDateTime | Returns: the local date-time, not nullthe year to represent, from MIN_YEAR to MAX_YEAR year, Month the month-of-year to represent, not null month, int the day-of-month to represent, from 1 to 31 dayOfMonth, int the hour-of-day to represent, from 0 to 23 hour, int the minute-of-hour to represent, from 0 to 59 minute)Obtains an instance of |
public static LocalDateTime | Returns: the local date-time, not nullthe year to represent, from MIN_YEAR to MAX_YEAR year, Month the month-of-year to represent, not null month, int the day-of-month to represent, from 1 to 31 dayOfMonth, int the hour-of-day to represent, from 0 to 23 hour, int the minute-of-hour to represent, from 0 to 59 minute, int the second-of-minute to represent, from 0 to 59 second)Obtains an instance of |
public static LocalDateTime | Returns: the local date-time, not nullthe year to represent, from MIN_YEAR to MAX_YEAR year, Month the month-of-year to represent, not null month, int the day-of-month to represent, from 1 to 31 dayOfMonth, int the hour-of-day to represent, from 0 to 23 hour, int the minute-of-hour to represent, 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)Obtains an instance of |
public static LocalDateTime | Returns: the local date-time, 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, int the hour-of-day to represent, from 0 to 23 hour, int the minute-of-hour to represent, from 0 to 59 minute)Obtains an instance of |
public static LocalDateTime | Returns: the local date-time, 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, int the hour-of-day to represent, from 0 to 23 hour, int the minute-of-hour to represent, from 0 to 59 minute, int the second-of-minute to represent, from 0 to 59 second)Obtains an instance of |
public static LocalDateTime | Returns: the local date-time, 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, int the hour-of-day to represent, from 0 to 23 hour, int the minute-of-hour to represent, 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)Obtains an instance of |
public static LocalDateTime | |
public static LocalDateTime | Returns: the local date-time, not nullthe number of seconds from the epoch of 1970-01-01T00:00:00Z epochSecond, int the nanosecond within the second, from 0 to 999,999,999 nanoOfSecond, ZoneOffset the zone offset, not null offset)Obtains an instance of |
public static LocalDateTime | Returns: the local date-time, not nullthe instant to create the date-time from, not null instant, ZoneId the time-zone, which may be an offset, not null zone)Obtains an instance of This creates a local date-time based on the specified instant. |
public static LocalDateTime | Returns: the parsed local date-time, not nullthe text to parse such as "2007-12-03T10:15:30", not null text)Obtains an instance of |
public static LocalDateTime | Returns: the parsed local date-time, not nullthe text to parse, not null text, DateTimeFormatter the formatter to use, not null formatter)Obtains an instance of |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the addition made, not nullthe amount to add, not null amountToAdd)Overrides default java. |
public LocalDateTime | Returns: aLocalDateTime based on this date-time 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)Implements java. |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the days added, not nullthe days to add, may be negative days)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the hours added, not nullthe hours to add, may be negative hours)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the minutes added, not nullthe minutes to add, may be negative minutes)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the months added, not nullthe months to add, may be negative months)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the nanoseconds added, not nullthe nanos to add, may be negative nanos)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the seconds added, not nullthe seconds to add, may be negative seconds)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the weeks added, not nullthe weeks to add, may be negative weeks)Returns a copy of this |
private LocalDateTime | Returns: the combined result, not nullthe new date to base the calculation on, not null newDate, long the hours to add, may be negative hours, long the minutes to add, may be negative minutes, long the seconds to add, may be negative seconds, long the nanos to add, may be negative nanos, int the sign to determine add or subtract sign)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the years added, not nullthe years to add, may be negative years)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. |
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. |
pack-priv static LocalDateTime | |
private void | |
public LocalDate | Returns: the date part of this date-time, not nullImplements java. LocalDate part of this date-time.
|
public LocalTime | Returns: the time part of this date-time, not nullImplements java. LocalTime part of this date-time.
|
public String | Returns: a string representation of this date-time, not nullOverrides java. Implements java. String , such as 2007-12-03T10:15:30 .
|
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the time truncated, not nullthe unit to truncate to, not null unit)Returns a copy of this |
public long | Returns: the amount of time between this date-time and the end date-timethe end date, exclusive, which is converted to a endExclusive, TemporalUnit LocalDateTime , not nullthe unit to measure the amount in, not null unit)Implements java. |
private LocalDateTime | |
public LocalDateTime | Returns: aLocalDateTime based on this with the adjustment made, not nullthe adjuster to use, not null adjuster)Overrides default java. |
public LocalDateTime | Returns: aLocalDateTime 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)Implements java. |
public LocalDateTime | Returns: aLocalDateTime based on this date-time 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 LocalDateTime | Returns: aLocalDateTime 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 LocalDateTime | Returns: aLocalDateTime based on this date-time with the requested hour, not nullthe hour-of-day to set in the result, from 0 to 23 hour)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the requested minute, not nullthe minute-of-hour to set in the result, from 0 to 59 minute)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time 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 LocalDateTime | Returns: aLocalDateTime based on this date-time with the requested nanosecond, not nullthe nano-of-second to set in the result, from 0 to 999,999,999 nanoOfSecond)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time with the requested second, not nullthe second-of-minute to set in the result, from 0 to 59 second)Returns a copy of this |
public LocalDateTime | Returns: aLocalDateTime based on this date-time 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. |