LocalDateTime

The representation of a specific civil date and time without a reference to a particular time zone.

This class does not describe specific moments in time, which are represented as Instant values. Instead, its instances can be thought of as clock readings, something that an observer in a particular time zone could witness. For example, 2020-08-30T18:43 is not a moment in time, since someone in Berlin and someone in Tokyo would witness this on their clocks at different times.

The main purpose of this class is to provide human-readable representations of Instant values, or to transfer them as data.

The arithmetic on LocalDateTime values is not provided, since without accounting for the time zone transitions it may give misleading results.

actual class LocalDateTime(val date: LocalDate, val time: LocalTime) : Comparable<LocalDateTime> (source)

Constructors

Link copied to clipboard
actual constructor(year: Int, monthNumber: Int, dayOfMonth: Int, hour: Int, minute: Int, second: Int, nanosecond: Int)
actual constructor(year: Int, month: Month, dayOfMonth: Int, hour: Int, minute: Int, second: Int, nanosecond: Int)
actual constructor(date: LocalDate, time: LocalTime)
expect constructor(year: Int, monthNumber: Int, dayOfMonth: Int, hour: Int, minute: Int, second: Int = 0, nanosecond: Int = 0)

Constructs a LocalDateTime instance from the given date and time components.

expect constructor(year: Int, month: Month, dayOfMonth: Int, hour: Int, minute: Int, second: Int = 0, nanosecond: Int = 0)

Constructs a LocalDateTime instance from the given date and time components.

expect constructor(date: LocalDate, time: LocalTime)

Constructs a LocalDateTime instance by combining the given date and time parts.

actual constructor(year: Int, monthNumber: Int, dayOfMonth: Int, hour: Int, minute: Int, second: Int, nanosecond: Int)
actual constructor(date: LocalDate, time: LocalTime)
actual constructor(year: Int, monthNumber: Int, dayOfMonth: Int, hour: Int, minute: Int, second: Int, nanosecond: Int)
actual constructor(year: Int, month: Month, dayOfMonth: Int, hour: Int, minute: Int, second: Int, nanosecond: Int)
actual constructor(date: LocalDate, time: LocalTime)

Types

Link copied to clipboard
actual object Companion
expect object Companion
actual object Companion
actual object Companion
Link copied to clipboard
actual object Formats
expect object Formats

A collection of predefined formats for parsing and formatting LocalDateTime values.

actual object Formats
actual object Formats

Properties

Link copied to clipboard
actual val date: LocalDate
expect val date: LocalDate

Returns the date part of this date/time value.

actual val date: LocalDate
actual val date: LocalDate
Link copied to clipboard
actual val dayOfMonth: Int
expect val dayOfMonth: Int

Returns the day-of-month component of the date.

actual val dayOfMonth: Int
actual val dayOfMonth: Int
Link copied to clipboard
actual val dayOfWeek: DayOfWeek
expect val dayOfWeek: DayOfWeek

Returns the day-of-week component of the date.

actual val dayOfWeek: DayOfWeek
actual val dayOfWeek: DayOfWeek
Link copied to clipboard
actual val dayOfYear: Int
expect val dayOfYear: Int

Returns the day-of-year component of the date.

actual val dayOfYear: Int
actual val dayOfYear: Int
Link copied to clipboard
actual val hour: Int
expect val hour: Int

Returns the hour-of-day time component of this date/time value.

actual val hour: Int
actual val hour: Int
Link copied to clipboard
actual val minute: Int
expect val minute: Int

Returns the minute-of-hour time component of this date/time value.

actual val minute: Int
actual val minute: Int
Link copied to clipboard
actual val month: Month
expect val month: Month

Returns the month (Month) component of the date.

actual val month: Month
actual val month: Month
Link copied to clipboard
actual val monthNumber: Int
expect val monthNumber: Int

Returns the number-of-month (1..12) component of the date.

actual val monthNumber: Int
actual val monthNumber: Int
Link copied to clipboard
actual val nanosecond: Int
expect val nanosecond: Int

Returns the nanosecond-of-second time component of this date/time value.

actual val nanosecond: Int
actual val nanosecond: Int
Link copied to clipboard
actual val second: Int
expect val second: Int

Returns the second-of-minute time component of this date/time value.

actual val second: Int
actual val second: Int
Link copied to clipboard
actual val time: LocalTime
expect val time: LocalTime

Returns the time part of this date/time value.

actual val time: LocalTime
actual val time: LocalTime
Link copied to clipboard
actual val year: Int
expect val year: Int

Returns the year component of the date.

actual val year: Int
actual val year: Int

Functions

Link copied to clipboard
actual open operator override fun compareTo(other: LocalDateTime): Int
expect open operator override fun compareTo(other: LocalDateTime): Int

Compares this date/time value with the other date/time value. Returns zero if this value is equal to the other, a negative number if this value represents earlier civil time than the other, and a positive number if this value represents later civil time than the other.

actual open operator override fun compareTo(other: LocalDateTime): Int
actual open operator override fun compareTo(other: LocalDateTime): Int
equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
open operator override fun equals(other: Any?): Boolean
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard

Formats this value using the given format. Equivalent to calling DateTimeFormat.format on format with this.

hashCode
Link copied to clipboard
open override fun hashCode(): Int
open override fun hashCode(): Int
open override fun hashCode(): Int
Link copied to clipboard
actual fun LocalDateTime.toInstant(timeZone: TimeZone): Instant
expect fun LocalDateTime.toInstant(timeZone: TimeZone): Instant

Returns an instant that corresponds to this civil date/time value in the specified timeZone.

Returns an instant that corresponds to this civil date/time value that happens at the specified UTC offset.

actual fun LocalDateTime.toInstant(timeZone: TimeZone): Instant
actual fun LocalDateTime.toInstant(timeZone: TimeZone): Instant
Link copied to clipboard
fun LocalDateTime.toNSDateComponents(): <Error class: unknown class>

Converts the given LocalDate to NSDateComponents.

Link copied to clipboard
actual open override fun toString(): String
expect open override fun toString(): String

Converts this date/time value to the ISO 8601 string representation.

actual open override fun toString(): String
actual open override fun toString(): String