Time

class Time(hour: Int, minute: Int, second: Int, nanosecond: Int) : Comparable<Time>

A time of day in an ambiguous region.

Parameters

hour

the hour of day

minute

the minute of the hour

second

the second of the minute

nanosecond

the nanosecond of the second

Throws

if the time is invalid

Constructors

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

Creates a Time from its individual components.

Types

Companion
Link copied to clipboard
common
object Companion

Functions

compareTo
Link copied to clipboard
common
open operator override fun compareTo(other: Time): Int
component1
Link copied to clipboard
common
operator fun component1(): Int
component2
Link copied to clipboard
common
operator fun component2(): Int
component3
Link copied to clipboard
common
operator fun component3(): Int
component4
Link copied to clipboard
common
operator fun component4(): Int
copy
Link copied to clipboard
common
fun copy(hour: Int = this.hour, minute: Int = this.minute, second: Int = this.second, nanosecond: Int = this.nanosecond): Time

Returns a copy of this time with the values of any individual components replaced by the new values specified.

equals
Link copied to clipboard
common
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
common
open override fun hashCode(): Int
minus
Link copied to clipboard
common
operator fun minus(duration: Duration): Time
operator fun minus(hours: Hours): Time

Returns this time with hours subtracted from it.

operator fun minus(microseconds: Microseconds): Time

Returns this time with microseconds subtracted from it.

operator fun minus(milliseconds: Milliseconds): Time

Returns this time with milliseconds subtracted from it.

operator fun minus(minutes: Minutes): Time

Returns this time with minutes subtracted from it.

operator fun minus(nanoseconds: Nanoseconds): Time

Returns this time with nanoseconds subtracted from it.

operator fun minus(seconds: Seconds): Time

Returns this time with seconds subtracted from it.

operator fun minus(duration: Duration): Time

Returns this time with duration subtracted from it.

plus
Link copied to clipboard
common
operator fun plus(duration: Duration): Time
operator fun plus(hours: Hours): Time

Returns this time with hours added to it.

operator fun plus(microseconds: Microseconds): Time

Returns this time with microseconds added to it.

operator fun plus(milliseconds: Milliseconds): Time

Returns this time with milliseconds added to it.

operator fun plus(minutes: Minutes): Time

Returns this time with minutes added to it.

operator fun plus(nanoseconds: Nanoseconds): Time

Returns this time with nanoseconds added to it.

operator fun plus(seconds: Seconds): Time

Returns this time with seconds added to it.

operator fun plus(duration: Duration): Time

Returns this time with duration added to it.

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

Converts this time to a string in ISO-8601 extended format. For example, 17:31:45.923452091 or 02:30.

Properties

hour
Link copied to clipboard
common
val hour: Int

The hour of the day.

minute
Link copied to clipboard
common
val minute: Int

The minute of the hour.

nanosecond
Link copied to clipboard
common
val nanosecond: Int = 0

The nanosecond of the second.

nanosecondOfDay
Link copied to clipboard
common
val nanosecondOfDay: Long

The nanosecond of the day.

nanosecondsSinceStartOfDay
Link copied to clipboard
common
val nanosecondsSinceStartOfDay: Nanoseconds

The number of nanoseconds since the start of the day.

second
Link copied to clipboard
common
val second: Int = 0

The second of the minute.

secondOfDay
Link copied to clipboard
common
val secondOfDay: Int

The second of the day.

secondsSinceStartOfDay
Link copied to clipboard
common
val secondsSinceStartOfDay: Seconds

The number of seconds since the start of the day.

Extensions

at
Link copied to clipboard
common
infix fun Time.at(offset: UtcOffset): OffsetTime

Combines a local time with a UTC offset to create an OffsetTime.

roundedDownTo
Link copied to clipboard
common
fun Time.roundedDownTo(unit: TimeUnit): Time

Returns this time, rounded down to match the precision of a given unit.

roundedDownToNearest
Link copied to clipboard
common
fun Time.roundedDownToNearest(increment: Hours): Time

Returns this time, rounded down to the nearest hour that satisfies the increment.

fun Time.roundedDownToNearest(increment: Minutes): Time

Returns this time, rounded down to the nearest minute that satisfies the increment.

fun Time.roundedDownToNearest(increment: Seconds): Time

Returns this time, rounded down to the nearest second that satisfies the increment.

fun Time.roundedDownToNearest(increment: Milliseconds): Time

Returns this time, rounded down to the nearest millisecond that satisfies the increment.

fun Time.roundedDownToNearest(increment: Microseconds): Time

Returns this time, rounded down to the nearest microsecond that satisfies the increment.

fun Time.roundedDownToNearest(increment: Nanoseconds): Time

Returns this time, rounded down to the nearest nanosecond that satisfies the increment.

roundedTo
Link copied to clipboard
common
fun Time.roundedTo(unit: TimeUnit): Time

Returns this time, rounded to match the precision of a given unit. If the time is halfway between whole values of the unit, it will be rounded up.

roundedToNearest
Link copied to clipboard
common
fun Time.roundedToNearest(increment: Hours): Time

Returns this time, rounded to the nearest hour that satisfies the increment. If the time is halfway between increments, it will be rounded up.

fun Time.roundedToNearest(increment: Minutes): Time

Returns this time, rounded to the nearest minute that satisfies the increment. If the time is halfway between increments, it will be rounded up.

fun Time.roundedToNearest(increment: Seconds): Time

Returns this time, rounded to the nearest second that satisfies the increment. If the time is halfway between increments, it will be rounded up.

fun Time.roundedToNearest(increment: Milliseconds): Time

Returns this time, rounded to the nearest millisecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

fun Time.roundedToNearest(increment: Microseconds): Time

Returns this time, rounded to the nearest microsecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

fun Time.roundedToNearest(increment: Nanoseconds): Time

Returns this time, rounded to the nearest nanosecond that satisfies the increment. If the time is halfway between increments, it will be rounded up.

roundedUpTo
Link copied to clipboard
common
fun Time.roundedUpTo(unit: TimeUnit): Time

Returns this time, rounded up to match the precision of a given unit.

roundedUpToNearest
Link copied to clipboard
common
fun Time.roundedUpToNearest(increment: Hours): Time

Returns this time, rounded up to the nearest hour that satisfies the increment.

fun Time.roundedUpToNearest(increment: Minutes): Time

Returns this time, rounded up to the nearest minute that satisfies the increment.

fun Time.roundedUpToNearest(increment: Seconds): Time

Returns this time, rounded up to the nearest second that satisfies the increment.

fun Time.roundedUpToNearest(increment: Milliseconds): Time

Returns this time, rounded up to the nearest millisecond that satisfies the increment.

fun Time.roundedUpToNearest(increment: Microseconds): Time

Returns this time, rounded up to the nearest microsecond that satisfies the increment.

fun Time.roundedUpToNearest(increment: Nanoseconds): Time

Returns this time, rounded up to the nearest nanosecond that satisfies the increment.

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

Converts this time to an equivalent Java LocalTime.

toNSDateComponents
Link copied to clipboard
darwin
fun Time.toNSDateComponents(includeCalendar: Boolean = false): <ERROR CLASS>

Converts this time to an equivalent NSDateComponents object.

truncatedTo
Link copied to clipboard
common
fun Time.truncatedTo(unit: TimeUnit): Time

Returns this time, rounded down to match the precision of a given unit.