public final class LocalDateTime extends Object implements Temporal, TemporalAdjuster, ChronoLocalDateTime<LocalDate>, Serializable
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; use of identity-sensitive operations (including reference equality
(==
), identity hash code, or synchronization) on instances of
LocalDateTime
may have unpredictable results and should be avoided.
The equals
method should be used for comparisons.
Modifier and Type | Field | Description |
---|---|---|
static LocalDateTime |
MAX |
The maximum supported
LocalDateTime , '+999999999-12-31T23:59:59.999999999'. |
static LocalDateTime |
MIN |
The minimum supported
LocalDateTime , '-999999999-01-01T00:00:00'. |
Modifier and Type | Method | Description |
---|---|---|
Temporal |
adjustInto(Temporal temporal) |
Adjusts the specified temporal object to have the same date and time as this object.
|
OffsetDateTime |
atOffset(ZoneOffset offset) |
Combines this date-time with an offset to create an
OffsetDateTime . |
ZonedDateTime |
atZone(ZoneId zone) |
Combines this date-time with a time-zone to create a
ZonedDateTime . |
int |
compareTo(ChronoLocalDateTime<?> other) |
Compares this date-time to another date-time.
|
boolean |
equals(Object obj) |
Checks if this date-time is equal to another date-time.
|
String |
format(DateTimeFormatter formatter) |
Formats this date-time using the specified formatter.
|
static LocalDateTime |
from(TemporalAccessor temporal) |
Obtains an instance of
LocalDateTime from a temporal object. |
int |
get(TemporalField field) |
Gets the value of the specified field from this date-time as an
int . |
int |
getDayOfMonth() |
Gets the day-of-month field.
|
DayOfWeek |
getDayOfWeek() |
Gets the day-of-week field, which is an enum
DayOfWeek . |
int |
|