Time

A time of day in an ambiguous region.

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

Parameters

hour

the hour of day

minute

the minute of the hour

nanosecond

the nanosecond of the second

second

the second of the minute

Constructors

Time
Link copied to clipboard
common

Creates a Time from its individual components.

fun Time(hour: Int, minute: Int, second: Int, nanosecond: Int)

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

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

fun copy(hour: Int, minute: Int, second: Int, nanosecond: Int): Time
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: LongHours): Time
operator fun minus(hours: IntHours): Time
operator fun minus(minutes: LongMinutes): Time
operator fun minus(minutes: IntMinutes): Time
operator fun minus(seconds: LongSeconds): Time
operator fun minus(seconds: IntSeconds): Time
operator fun minus(milliseconds: LongMilliseconds): Time
operator fun minus(milliseconds: IntMilliseconds): Time
operator fun minus(microseconds: LongMicroseconds): Time
operator fun minus(microseconds: IntMicroseconds): Time
operator fun minus(nanoseconds: LongNanoseconds): Time
operator fun minus(nanoseconds: IntNanoseconds): Time
plus
Link copied to clipboard
common
operator fun plus(duration: Duration): Time
operator fun plus(hours: LongHours): Time
operator fun plus(hours: IntHours): Time
operator fun plus(minutes: LongMinutes): Time
operator fun plus(minutes: IntMinutes): Time
operator fun plus(seconds: LongSeconds): Time
operator fun plus(seconds: IntSeconds): Time
operator fun plus(milliseconds: LongMilliseconds): Time
operator fun plus(milliseconds: IntMilliseconds): Time
operator fun plus(microseconds: LongMicroseconds): Time
operator fun plus(microseconds: IntMicroseconds): Time
operator fun plus(nanoseconds: LongNanoseconds): Time
operator fun plus(nanoseconds: IntNanoseconds): Time
toString
Link copied to clipboard
common

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

open override fun toString(): String

Properties

hour
Link copied to clipboard
common

The hour of the day.

val hour: Int
minute
Link copied to clipboard
common

The minute of the hour.

val minute: Int
nanosecond
Link copied to clipboard
common

The nanosecond of the second.

val nanosecond: Int
nanosecondOfDay
Link copied to clipboard
common

The nanosecond of the day.

val nanosecondOfDay: Long
nanosecondsSinceStartOfDay
Link copied to clipboard
common

The number of nanoseconds since the start of the day.

val nanosecondsSinceStartOfDay: LongNanoseconds
second
Link copied to clipboard
common

The second of the minute.

val second: Int
secondOfDay
Link copied to clipboard
common

The second of the day.

val secondOfDay: Int
secondsSinceStartOfDay
Link copied to clipboard
common

The number of seconds since the start of the day.

val secondsSinceStartOfDay: IntSeconds

Extensions

at
Link copied to clipboard
common

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

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

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

This is equivalent to truncatedTo.

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

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

The increment must multiply evenly into a 24-hour day.

fun Time.roundedDownToNearest(increment: IntHours): Time

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

The increment must multiply evenly into an hour.

fun Time.roundedDownToNearest(increment: IntMinutes): Time

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

The increment must multiply evenly into a minute.

fun Time.roundedDownToNearest(increment: IntSeconds): Time

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

The increment must multiply evenly into a second.

fun Time.roundedDownToNearest(increment: IntMilliseconds): Time

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

The increment must multiply evenly into a second.

fun Time.roundedDownToNearest(increment: IntMicroseconds): Time

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

The increment must multiply evenly into a second.

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

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.

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

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

The increment must multiply evenly into a 24-hour day.

fun Time.roundedToNearest(increment: IntHours): 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.

The increment must multiply evenly into an hour.

fun Time.roundedToNearest(increment: IntMinutes): 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.

The increment must multiply evenly into a minute.

fun Time.roundedToNearest(increment: IntSeconds): 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.

The increment must multiply evenly into a second.

fun Time.roundedToNearest(increment: IntMilliseconds): 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.

The increment must multiply evenly into a second.

fun Time.roundedToNearest(increment: IntMicroseconds): 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.

The increment must multiply evenly into a second.

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

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

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

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

The increment must multiply evenly into a 24-hour day.

fun Time.roundedUpToNearest(increment: IntHours): Time

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

The increment must multiply evenly into an hour.

fun Time.roundedUpToNearest(increment: IntMinutes): Time

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

The increment must multiply evenly into a minute.

fun Time.roundedUpToNearest(increment: IntSeconds): Time

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

The increment must multiply evenly into a second.

fun Time.roundedUpToNearest(increment: IntMilliseconds): Time

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

The increment must multiply evenly into a second.

fun Time.roundedUpToNearest(increment: IntMicroseconds): Time

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

The increment must multiply evenly into a second.

fun Time.roundedUpToNearest(increment: IntNanoseconds): Time
toJavaLocalTime
Link copied to clipboard

Converts this time to an equivalent Java LocalTime.

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

Converts this time to an equivalent NSDateComponents object.

fun Time.toNSDateComponents(includeCalendar: Boolean): <ERROR CLASS>
truncatedTo
Link copied to clipboard
common

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

This is equivalent to roundedDownTo.

fun Time.truncatedTo(unit: TimeUnit): Time