Time¶
@Serializable(with = TimeIsoSerializer::class)
class Time(val hour: Int, val minute: Int, val second: Int = 0, val nanosecond: Int = 0) : Comparable<Time>
A time of day in an ambiguous region.
Parameters¶
common
| hour | the hour of day |
| minute | the minute of the hour |
| second | the second of the minute |
| nanosecond | the nanosecond of the second |
Throws¶
| DateTimeException | if the time is invalid |
Constructors¶
| Time | common constructor(hour: Int, minute: Int, second: Int = 0, nanosecond: Int = 0)Creates a Time from its individual components. |
Types¶
| Name | Summary |
|---|---|
| Companion | common object Companion |
Properties¶
| Name | Summary |
|---|---|
| hour | common val hour: IntThe hour of the day. |
| minute | common val minute: IntThe minute of the hour. |
| nanosecond | common val nanosecond: Int = 0The nanosecond of the second. |
| nanosecondOfDay | common val nanosecondOfDay: LongThe nanosecond of the day. |
| nanosecondsSinceStartOfDay | common val nanosecondsSinceStartOfDay: NanosecondsThe number of nanoseconds since the start of the day. |
| second | common val second: Int = 0The second of the minute. |
| secondOfDay | common val secondOfDay: IntThe second of the day. |
| secondsSinceStartOfDay | common val secondsSinceStartOfDay: SecondsThe number of seconds since the start of the day. |
Functions¶
| Name | Summary |
|---|---|
| at | common infix fun Time.at(offset: UtcOffset): OffsetTimeCombines a local time with a UTC offset to create an OffsetTime. |
| compareTo | common open operator override fun compareTo(other: Time): Int |
| component1 | common operator fun component1(): Int |
| component2 | common operator fun component2(): Int |
| component3 | common operator fun component3(): Int |
| component4 | common operator fun component4(): Int |
| copy | common fun copy(hour: Int = this.hour, minute: Int = this.minute, second: Int = this.second, nanosecond: Int = this.nanosecond): TimeReturns a copy of this time with the values of any individual components replaced by the new values specified. |
| equals | common open operator override fun equals(other: Any?): Boolean |
| hashCode | common open override fun hashCode(): Int |
| minus | common operator fun minus(duration: Duration): Timecommon operator fun minus(hours: Hours): TimeReturns this time with hours subtracted from it. common operator fun minus(microseconds: Microseconds): TimeReturns this time with microseconds subtracted from it. common operator fun minus(milliseconds: Milliseconds): TimeReturns this time with milliseconds subtracted from it. common operator fun minus(minutes: Minutes): TimeReturns this time with minutes subtracted from it. common operator fun minus(nanoseconds: Nanoseconds): TimeReturns this time with nanoseconds subtracted from it. common operator fun minus(seconds: Seconds): TimeReturns this time with seconds subtracted from it. common operator fun minus(duration: Duration): TimeReturns this time with duration subtracted from it. |
| plus | common operator fun plus(duration: Duration): Timecommon operator fun plus(hours: Hours): TimeReturns this time with hours added to it. common operator fun plus(microseconds: Microseconds): TimeReturns this time with microseconds added to it. common operator fun plus(milliseconds: Milliseconds): TimeReturns this time with milliseconds added to it. common operator fun plus(minutes: Minutes): TimeReturns this time with minutes added to it. common operator fun plus(nanoseconds: Nanoseconds): TimeReturns this time with nanoseconds added to it. common operator fun plus(seconds: Seconds): TimeReturns this time with seconds added to it. common operator fun plus(duration: Duration): TimeReturns this time with duration added to it. |
| roundedDownTo | common fun Time.roundedDownTo(unit: TimeUnit): TimeReturns this time, rounded down to match the precision of a given unit. |
| roundedDownToNearest | common fun Time.roundedDownToNearest(increment: Hours): TimeReturns this time, rounded down to the nearest hour that satisfies the increment. common fun Time.roundedDownToNearest(increment: Microseconds): TimeReturns this time, rounded down to the nearest microsecond that satisfies the increment. common fun Time.roundedDownToNearest(increment: Milliseconds): TimeReturns this time, rounded down to the nearest millisecond that satisfies the increment. common fun Time.roundedDownToNearest(increment: Minutes): TimeReturns this time, rounded down to the nearest minute that satisfies the increment. common fun Time.roundedDownToNearest(increment: Nanoseconds): TimeReturns this time, rounded down to the nearest nanosecond that satisfies the increment. common fun Time.roundedDownToNearest(increment: Seconds): TimeReturns this time, rounded down to the nearest second that satisfies the increment. |
| roundedTo | common fun Time.roundedTo(unit: TimeUnit): TimeReturns 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 | common fun Time.roundedToNearest(increment: Hours): TimeReturns this time, rounded to the nearest hour that satisfies the increment. If the time is halfway between increments, it will be rounded up. common fun Time.roundedToNearest(increment: Microseconds): TimeReturns this time, rounded to the nearest microsecond that satisfies the increment. If the time is halfway between increments, it will be rounded up. common fun Time.roundedToNearest(increment: Milliseconds): TimeReturns this time, rounded to the nearest millisecond that satisfies the increment. If the time is halfway between increments, it will be rounded up. common fun Time.roundedToNearest(increment: Minutes): TimeReturns this time, rounded to the nearest minute that satisfies the increment. If the time is halfway between increments, it will be rounded up. common fun Time.roundedToNearest(increment: Nanoseconds): TimeReturns this time, rounded to the nearest nanosecond that satisfies the increment. If the time is halfway between increments, it will be rounded up. common fun Time.roundedToNearest(increment: Seconds): TimeReturns this time, rounded to the nearest second that satisfies the increment. If the time is halfway between increments, it will be rounded up. |
| roundedUpTo | common fun Time.roundedUpTo(unit: TimeUnit): TimeReturns this time, rounded up to match the precision of a given unit. |
| roundedUpToNearest | common fun Time.roundedUpToNearest(increment: Hours): TimeReturns this time, rounded up to the nearest hour that satisfies the increment. common fun Time.roundedUpToNearest(increment: Microseconds): TimeReturns this time, rounded up to the nearest microsecond that satisfies the increment. common fun Time.roundedUpToNearest(increment: Milliseconds): TimeReturns this time, rounded up to the nearest millisecond that satisfies the increment. common fun Time.roundedUpToNearest(increment: Minutes): TimeReturns this time, rounded up to the nearest minute that satisfies the increment. common fun Time.roundedUpToNearest(increment: Nanoseconds): TimeReturns this time, rounded up to the nearest nanosecond that satisfies the increment. common fun Time.roundedUpToNearest(increment: Seconds): TimeReturns this time, rounded up to the nearest second that satisfies the increment. |
| toJavaLocalTime | jvm fun Time.toJavaLocalTime(): LocalTimeConverts this time to an equivalent Java LocalTime. |
| toNSDateComponents | darwin fun Time.toNSDateComponents(includeCalendar: Boolean = false): <Error class: unknown class>Converts this time to an equivalent NSDateComponents object. |
| toString | common open override fun toString(): StringConverts this time to a string in ISO-8601 extended format. For example, 17:31:45.923452091 or 02:30. |
| truncatedTo | common fun Time.truncatedTo(unit: TimeUnit): TimeReturns this time, rounded down to match the precision of a given unit. |