Added in API level 26

LocalDateTime

class LocalDateTime : ChronoLocalDateTime<LocalDate!>, Serializable, Temporal, TemporalAdjuster
kotlin.Any
   ↳ java.time.LocalDateTime

A date-time without a time-zone in the ISO-8601 calendar system, such as 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.

Summary

Public methods
Temporal!
adjustInto(temporal: Temporal!)

Adjusts the specified temporal object to have the same date and time as this object.

OffsetDateTime!
atOffset(offset: ZoneOffset!)

Combines this date-time with an offset to create an OffsetDateTime.

ZonedDateTime!
atZone(zone: ZoneId!)

Combines this date-time with a time-zone to create a ZonedDateTime.

Int

Compares this date-time to another date-time.

Boolean
equals(other: Any?)

Checks if this date-time is equal to another date-time.

String!

Formats this date-time using the specified formatter.

static LocalDateTime!
from(temporal: TemporalAccessor!)

Obtains an instance of LocalDateTime from a temporal object.

Int
get(field: TemporalField!)

Gets the value of the specified field from this date-time as an int.

Int

Gets the day-of-month field.

DayOfWeek!

Gets the day-of-week field, which is an enum DayOfWeek.

Int

Gets the day-of-year field.

Int

Gets the hour-of-day field.

Long

Gets the value of the specified field from this date-time as a long.

Int

Gets the minute-of-hour field.

Month!

Gets the month-of-year field using the Month enum.

Int

Gets the month-of-year field from 1 to 12.

Int

Gets the nano-of-second field.

Int

Gets the second-of-minute field.

Int

Gets the year field.

Int

A hash code for this date-time.

Boolean

Checks if this date-time is after the specified date-time.

Boolean

Checks if this date-time is before the specified date-time.

Boolean

Checks if this date-time is equal to the specified date-time.

Boolean

Checks if the specified field is supported.

Boolean

Checks if the specified unit is supported.

LocalDateTime!
minus(amountToSubtract: TemporalAmount!)

Returns a copy of this date-time with the specified amount subtracted.

LocalDateTime!
minus(amountToSubtract: Long, unit: TemporalUnit!)

Returns a copy of this date-time with the specified amount subtracted.

LocalDateTime!
minusDays(days: Long)

Returns a copy of this LocalDateTime with the specified number of days subtracted.

LocalDateTime!
minusHours(hours: Long)

Returns a copy of this LocalDateTime with the specified number of hours subtracted.

LocalDateTime!
minusMinutes(minutes: Long)

Returns a copy of this LocalDateTime with the specified number of minutes subtracted.

LocalDateTime!
minusMonths(months: Long)

Returns a copy of this LocalDateTime with the specified number of months subtracted.

LocalDateTime!
minusNanos(nanos: Long)

Returns a copy of this LocalDateTime with the specified number of nanoseconds subtracted.

LocalDateTime!
minusSeconds(seconds: Long)

Returns a copy of this LocalDateTime with the specified number of seconds subtracted.

LocalDateTime!
minusWeeks(weeks: Long)

Returns a copy of this LocalDateTime with the specified number of weeks subtracted.

LocalDateTime!
minusYears(years: Long)

Returns a copy of this LocalDateTime with the specified number of years subtracted.

static LocalDateTime!
now()

Obtains the current date-time from the system clock in the default time-zone.

static LocalDateTime!
now(clock: Clock!)

Obtains the current date-time from the specified clock.

static LocalDateTime!
now(zone: ZoneId!)

Obtains the current date-time from the system clock in the specified time-zone.

static LocalDateTime!
of(year: Int, month: Int, dayOfMonth: Int, hour: Int, minute: Int)

Obtains an instance of LocalDateTime from year, month, day, hour and minute, setting the second and nanosecond to zero.

static LocalDateTime!
of(year: Int, month: Int, dayOfMonth: Int, hour: Int, minute: Int, second: Int)

Obtains an instance of LocalDateTime from year, month, day, hour, minute and second, setting the nanosecond to zero.

static LocalDateTime!
of(year: Int, month: Int, dayOfMonth: Int, hour: Int, minute: Int, second: Int, nanoOfSecond: Int)

Obtains an instance of LocalDateTime from year, month, day, hour, minute, second and nanosecond.

static LocalDateTime!
of(year: Int, month: Month!, dayOfMonth: Int, hour: Int, minute: Int)

Obtains an instance of LocalDateTime from year, month, day, hour and minute, setting the second and nanosecond to zero.

static LocalDateTime!
of(year: Int, month: Month!, dayOfMonth: Int, hour: Int, minute: Int, second: Int)

Obtains an instance of LocalDateTime from year, month, day, hour, minute and second, setting the nanosecond to zero.

static LocalDateTime!
of(year: Int, month: Month!, dayOfMonth: Int, hour: Int, minute: Int, second: Int, nanoOfSecond: Int)

Obtains an instance of LocalDateTime from year, month, day, hour, minute, second and nanosecond.

static LocalDateTime!
of(date: LocalDate!, time: LocalTime!)

Obtains an instance of LocalDateTime from a date and time.

static LocalDateTime!
ofEpochSecond(epochSecond: Long, nanoOfSecond: Int, offset: ZoneOffset!)

Obtains an instance of LocalDateTime using seconds from the epoch of 1970-01-01T00:00:00Z.

static LocalDateTime!
ofInstant(instant: Instant!, zone: ZoneId!)

Obtains an instance of LocalDateTime from an Instant and zone ID.

static LocalDateTime!

Obtains an instance of LocalDateTime from a text string such as 2007-12-03T10:15:30.

static LocalDateTime!
parse(text: CharSequence!, formatter: DateTimeFormatter!)

Obtains an instance of LocalDateTime from a text string using a specific formatter.

LocalDateTime!
plus(amountToAdd: TemporalAmount!)

Returns a copy of this date-time with the specified amount added.

LocalDateTime!
plus(amountToAdd: Long, unit: TemporalUnit!)

Returns a copy of this date-time with the specified amount added.

LocalDateTime!
plusDays(days: Long)

Returns a copy of this LocalDateTime with the specified number of days added.

LocalDateTime!
plusHours(hours: Long)

Returns a copy of this LocalDateTime with the specified number of hours added.

LocalDateTime!
plusMinutes(minutes: Long)

Returns a copy of this LocalDateTime with the specified number of minutes added.

LocalDateTime!
plusMonths(months: Long)

Returns a copy of this LocalDateTime with the specified number of months added.

LocalDateTime!
plusNanos(nanos: Long)

Returns a copy of this LocalDateTime with the specified number of nanoseconds added.

LocalDateTime!
plusSeconds(seconds: Long)

Returns a copy of this LocalDateTime with the specified number of seconds added.

LocalDateTime!
plusWeeks(weeks: Long)

Returns a copy of this LocalDateTime with the specified number of weeks added.

LocalDateTime!
plusYears(years: Long)

Returns a copy of this LocalDateTime with the specified number of years added.

R
query(query: TemporalQuery<R>!)

Queries this date-time using the specified query.

ValueRange!

Gets the range of valid values for the specified field.

LocalDate!

Gets the LocalDate part of this date-time.

LocalTime!

Gets the LocalTime part of this date-time.

String

Outputs this date-time as a String, such as 2007-12-03T10:15:30.

LocalDateTime!

Returns a copy of this LocalDateTime with the time truncated.

Long
until(endExclusive: Temporal!, unit: TemporalUnit!)

Calculates the amount of time until another date-time in terms of the specified unit.

LocalDateTime!
with(adjuster: TemporalAdjuster!)

Returns an adjusted copy of this date-time.

LocalDateTime!
with(field: TemporalField!, newValue: Long)

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

LocalDateTime!
withDayOfMonth(dayOfMonth: Int)

Returns a copy of this LocalDateTime with the day-of-month altered.

LocalDateTime!
withDayOfYear(dayOfYear: Int)

Returns a copy of this LocalDateTime with the day-of-year altered.

LocalDateTime!
withHour(hour: Int)

Returns a copy of this LocalDateTime with the hour-of-day altered.

LocalDateTime!
withMinute(minute: Int)

Returns a copy of this LocalDateTime with the minute-of-hour altered.

LocalDateTime!
withMonth(month: Int)

Returns a copy of this LocalDateTime with the month-of-year altered.

LocalDateTime!
withNano(nanoOfSecond: Int)

Returns a copy of this LocalDateTime with the nano-of-second altered.

LocalDateTime!
withSecond(second: Int)

Returns a copy of this LocalDateTime with the second-of-minute altered.

LocalDateTime!
withYear(year: Int)

Returns a copy of this LocalDateTime with the year altered.

Inherited functions