LocalTime

expect class LocalTime(    hour: Int,     minute: Int,     second: Int = 0,     nanosecond: Int = 0) : Comparable<LocalTime>

The time part of LocalDateTime.

This class represents time-of-day without a referencing a specific date. To reconstruct a full LocalDateTime, representing civil date and time, LocalTime needs to be combined with LocalDate via LocalDate.atTime or LocalTime.atDate.

Also, LocalTime does not reference a particular time zone. Therefore, even on the same date, LocalTime denotes different moments of time. For example, 18:43 happens at different moments in Berlin and in Tokyo.

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

actual class LocalTime(    hour: Int,     minute: Int,     second: Int,     nanosecond: Int) : Comparable<LocalTime>
actual class LocalTime(    hour: Int,     minute: Int,     second: Int,     nanosecond: Int) : Comparable<LocalTime>
actual class LocalTime(    val hour: Int,     val minute: Int,     val second: Int,     val nanosecond: Int) : Comparable<LocalTime>

Constructors

Link copied to clipboard
expect fun LocalTime(    hour: Int,     minute: Int,     second: Int = 0,     nanosecond: Int = 0)

Constructs a LocalTime instance from the given time components.

actual fun LocalTime(    hour: Int,     minute: Int,     second: Int,     nanosecond: Int)
actual fun LocalTime(    hour: Int,     minute: Int,     second: Int,     nanosecond: Int)
actual fun LocalTime(    hour: Int,     minute: Int,     second: Int,     nanosecond: Int)

Types

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

Functions

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

Compares this time value with the other time value. Returns zero if this value is equal to the other, a negative number if this value occurs earlier in the course of a typical day than the other, and a positive number if this value occurs later in the course of a typical day than the other.

actual open operator override fun compareTo(other: LocalTime): Int
actual open operator override fun compareTo(other: LocalTime): Int
actual open operator override fun compareTo(other: LocalTime): 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
hashCode
Link copied to clipboard
open override fun hashCode(): Int
open override fun hashCode(): Int
open override fun hashCode(): Int
Link copied to clipboard
expect fun toMillisecondOfDay(): Int

Returns the time as a millisecond of a day, in 0 until 24 * 60 * 60 * 1_000.

actual fun toMillisecondOfDay(): Int
actual fun toMillisecondOfDay(): Int
actual fun toMillisecondOfDay(): Int
Link copied to clipboard
expect fun toNanosecondOfDay(): Long

Returns the time as a nanosecond of a day, in 0 until 24 * 60 * 60 * 1_000_000_000.

actual fun toNanosecondOfDay(): Long
actual fun toNanosecondOfDay(): Long
actual fun toNanosecondOfDay(): Long
Link copied to clipboard
expect fun toSecondOfDay(): Int

Returns the time as a second of a day, in 0 until 24 * 60 * 60.

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

Converts this time value to the ISO-8601 string representation.

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

Properties

Link copied to clipboard
expect val hour: Int

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

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

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

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

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

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

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

actual val second: Int
actual val second: Int
actual val second: Int

Extensions

Link copied to clipboard
fun LocalTime.atDate(    year: Int,     monthNumber: Int,     dayOfMonth: Int = 0): LocalDateTime
fun LocalTime.atDate(    year: Int,     month: Month,     dayOfMonth: Int = 0): LocalDateTime

Combines this time's components with the specified date components into a LocalDateTime value.

fun LocalTime.atDate(date: LocalDate): LocalDateTime

Combines this time's components with the specified LocalDate components into a LocalDateTime value.

Link copied to clipboard
fun LocalTime.toJavaLocalTime(): LocalTime

Converts this kotlinx.datetime.LocalDateTime value to a java.time.LocalTime value.