The java.time.LocalDateTime class represents a date-time without a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30.
Following is the declaration for java.time.LocalDateTime class −
public final class LocalDateTime extends Object implements Temporal, TemporalAdjuster, ChronoLocalDateTime, Serializable
Following are the fields for java.time.LocalDateTime class −
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'.
Sr.No. | Method & Description |
---|---|
1 | Temporal adjustInto(Temporal temporal)
Adjusts the specified temporal object to have the same date and time as this object. |
2 | OffsetDateTime atOffset(ZoneOffset offset)
Combines this date-time with an offset time to create an OffsetDateTime. |
3 | ZonedDateTime atZone(ZoneId zone)
Combines this date-time with a timezone to create a ZonedDateTime. |
4 | int compareTo(ChronoLocalDateTime<?> other)
Compares this date-time to another date-time. |
5 | boolean equals(Object obj)
Checks if this date-time is equal to another date-time. |
6 | String format(DateTimeFormatter formatter)
Formats this date-time using the specified formatter. |
7 | static LocalDateTime from(TemporalAccessor temporal)
Obtains an instance of LocalDateTime from a temporal object. |
8 | int get(TemporalField field)
Gets the value of the specified field from this date-time as an int. |
9 | int getDayOfMonth()
Gets the day-of-month field. |
10 | DayOfWeek getDayOfWeek()
Gets the day-of-week field, which is an enum DayOfWeek. |
11 | int getDayOfYear()
Gets the day-of-year field. |
12 | int getHour()
Gets the hour-of-day field. |
13 | long getLong(TemporalField field)
Gets the value of the specified field from this date-time as a long. |
14 | Month getMinute()
Gets the minute-of-hour field. |
15 | Month getMonth()
Gets the month-of-year field using the Month enum. |
16 | int getMonthValue()
Gets the month-of-year field from 1 to 12. |
17 | int getNano()
Gets the nano-of-second field. |
18 | int getSecond()
Gets the second-of-minute field. |
19 | int getYear()
Gets the year field. |
20 | int hashCode()
A hash code for this date-time. |
21 | boolean isAfter(ChronoLocalDateTime<?> other)
Checks if this date-time is after the specified date-time. |
22 | boolean isBefore(ChronoLocalDateTime<?> other)
Checks if this date-time is before the specified date-time. |
23 | boolean isEqual(ChronoLocalDateTime<?> other)
Checks if this date-time is equal to the specified date-time. |
24 | boolean isSupported(TemporalField field)
Checks if the specified field is supported. |
25 | boolean isSupported(TemporalUnit unit)
Checks if the specified unit is supported. |
26 | LocalDateTime minus(long amountToSubtract, TemporalUnit unit)
Returns a copy of this date-time with the specified amount subtracted. |
27 | LocalDateTime
minus(TemporalAmount amountToSubtract)
Returns a copy of this date-time with the specified amount subtracted. |
28 | LocalDateTime minusDays(long daysToSubtract)
Returns a copy of this LocalDateTime with the specified number of days subtracted. |
29 | LocalDateTime minusHours(long hoursToSubtract)
Returns a copy of this LocalDateTime with the specified number of hours subtracted. |
30 | LocalDateTime minusMinutes(long minutesToSubtract)
Returns a copy of this LocalDateTime with the specified number of minutes subtracted. |
31 | LocalDateTime minusMonths(long monthsToSubtract)
Returns a copy of this LocalDateTime with the specified number of months subtracted. |
32 | LocalDateTime minusNanos(long nanos)
Returns a copy of this LocalDateTime with the specified number of nanoseconds subtracted. |
33 | LocalDateTime minusSeconds(long seconds)
Returns a copy of this LocalDateTime with the specified number of seconds subtracted. |
34 | LocalDateTime minusWeeks(long weeksToSubtract)
Returns a copy of this LocalDateTime with the specified number of weeks subtracted. |
35 | LocalDateTime minusYears(long yearsToSubtract)
Returns a copy of this LocalDateTime with the specified number of years subtracted. |
36 | static LocalDateTime now()
Obtains the current date-time from the system clock in the default time-zone. |
37 | static LocalDateTime now(Clock clock)
Obtains the current date-time from the specified clock. |
38 | static LocalDateTime now(ZoneId zone)
Obtains the current date-time from the system clock in the specified time-zone. |
39 | static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute)
Obtains an instance of LocalDateTime from year, month, day, hour and minute, setting the second and nanosecond to zero. |
40 | static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute, int second)
Obtains an instance of LocalDateTime from year, month, day, hour, minute and second, setting the nanosecond to zero. |
41 | static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond)
Obtains an instance of LocalDateTime from year, month, day, hour, minute, second and nanosecond. |
42 | static LocalDateTime of(int year, Month month, int dayOfMonth, int hour, int minute, int second)
Obtains an instance of LocalDateTime from year, month, day, hour, minute and second, setting the nanosecond to zero. |
43 | static LocalDateTime of(int year, Month month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond)
Obtains an instance of LocalDateTime from year, month, day, hour, minute, second and nanosecond. |
44 | static LocalDateTime of(LocalDate date, LocalTime time)
Obtains an instance of LocalDateTime from a date and time. |
45 | static LocalDateTime ofEpochSecond(long epochSecond, int nanoOfSecond, ZoneOffset offset)
Obtains an instance of LocalDateTime from the epoch of 1970-01-01T00:00:00Z. |
46 | static LocalDateTime ofInstant(Instant instant, ZoneId zone)
Obtains an instance of LocalDateTime from an Instant and zone ID. |
47 | static LocalDateTime parse(CharSequence text)
Obtains an instance of LocalDateTime from a text string such as 2007-12-03T10:15:30. |
48 | static LocalDateTime parse(CharSequence text, DateTimeFormatter formatter)
Obtains an instance of LocalDateTime from a text string using a specific formatter. |
49 | LocalDateTime plus(long amountToAdd, TemporalUnit unit)
Returns a copy of this date-time with the specified amount added. |
50 | LocalDateTime plus(TemporalAmount amountToAdd)
Returns a copy of this date-time with the specified amount added. |
51 | LocalDateTime plusDays(long daysToAdd)
Returns a copy of this LocalDateTime with the specified number of days added. |
52 | LocalDateTime plusHours(long hoursToAdd)
Returns a copy of this LocalDateTime with the specified number of hours added. |
53 | LocalDateTime plusMinutes(long minutesToAdd)
Returns a copy of this LocalDateTime with the specified number of minutes added. |
54 | LocalDateTime plusMonths(long monthsToAdd)
Returns a copy of this LocalDateTime with the specified number of months added. |
55 | LocalDateTime plusNanos(long nanos)
Returns a copy of this LocalDateTime with the specified number of nanoseconds added. |
56 | LocalDateTime plusSeconds(long seconds)
Returns a copy of this LocalDateTime with the specified number of seconds added. |
57 | LocalDateTime plusWeeks(long weeksToAdd)
Returns a copy of this LocalDateTime with the specified number of weeks added. |
58 | LocalDateTime plusYears(long yearsToAdd)
Returns a copy of this LocalDateTime with the specified number of years added. |
59 | <R> R query(TemporalQuery<R> query)
Queries this date-time using the specified query. |
60 | ValueRange range(TemporalField field)
Gets the range of valid values for the specified field. |
61 | LocalDate toLocalDate()
Gets the LocalDate part of this date-time. |
62 | LocalTime toLocalTime()
Gets the LocalTime part of this date-time. |
63 | String toString()
Outputs this date as a String, such as 2007-12-03T10:15:30. |
64 | LocalDateTime truncatedTo(TemporalUnit unit)
Returns a copy of this LocalDateTime with the time truncated. |
65 | long until(Temporal endExclusive, TemporalUnit unit)
Calculates the amount of time until another date-time in terms of the specified unit. |
66 | LocalDateTime with(TemporalAdjuster adjuster)
Returns an adjusted copy of this date-time. |
67 | LocalDateTime with(TemporalField field, long newValue)
Returns a copy of this date-time with the specified field set to a new value. |
68 | LocalDateTime withDayOfMonth(int dayOfMonth)
Returns a copy of this LocalDateTime with the day-of-month altered. |
69 | LocalDateTime withDayOfYear(int dayOfYear)
Returns a copy of this LocalDateTime with the day-of-year altered. |
70 | LocalDateTime withHour(int hour)
Returns a copy of this LocalDateTime with the hour-of-day altered. |
71 | LocalDateTime withMinute(int minute)
Returns a copy of this LocalDateTime with the minute-of-hour altered. |
72 | LocalDateTime withMonth(int month)
Returns a copy of this LocalDateTime with the month-of-year altered. |
73 | LocalDateTime withNano(int nanoOfSecond)
Returns a copy of this LocalDateTime with the nano-of-second altered. |
74 | LocalDateTime withSecond(int second)
Returns a copy of this LocalDateTime with the second-of-minute altered. |
75 | LocalDateTime withYear(int year)
Returns a copy of this LocalDateTime with the year altered. |
This class inherits methods from the following classes −