//core/io.islandtime/OffsetTime
OffsetTime¶
@Serializable(with = OffsetTimeIsoSerializer::class)
class OffsetTime(val time: Time, val offset: UtcOffset)
A time of day with an offset from UTC.
Throws¶
| DateTimeException | if the offset is invalid |
Constructors¶
| OffsetTime | common constructor(hour: Int, minute: Int, second: Int = 0, nanosecond: Int = 0, offset: UtcOffset)Creates an OffsetTime. constructor(time: Time, offset: UtcOffset)Creates an OffsetTime by combining a Time and UtcOffset. |
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: IntThe nanosecond of the second. |
| nanosecondsSinceStartOfUtcDay | common val nanosecondsSinceStartOfUtcDay: NanosecondsThe number of nanoseconds since the start of the day, but normalized to a UTC offset of zero, allowing OffsetTime objects with different offsets to be compared. |
| offset | common val offset: UtcOffsetThe offset from UTC. |
| second | common val second: IntThe second of the minute. |
| time | common val time: TimeThe time of day. |
Functions¶
| Name | Summary |
|---|---|
| adjustedTo | common fun adjustedTo(newOffset: UtcOffset): OffsetTimeChanges the offset of this OffsetTime, adjusting the time component such that the instant represented by it remains the same. |
| compareTo | common operator fun compareTo(other: OffsetTime): IntCompares to another OffsetTime based on timeline order, ignoring offset differences. |
| copy | common fun copy(time: Time = this.time, offset: UtcOffset = this.offset): OffsetTimefun copy(hour: Int = this.hour, minute: Int = this.minute, second: Int = this.second, nanosecond: Int = this.nanosecond, offset: UtcOffset = this.offset): OffsetTimeReturns 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): OffsetTimecommon operator fun minus(hours: Hours): OffsetTimeReturns this time with hours subtracted from it. common operator fun minus(microseconds: Microseconds): OffsetTimeReturns this time with microseconds subtracted from it. common operator fun minus(milliseconds: Milliseconds): OffsetTimeReturns this time with milliseconds subtracted from it. common operator fun minus(minutes: Minutes): OffsetTimeReturns this time with minutes subtracted from it. common operator fun minus(nanoseconds: Nanoseconds): OffsetTimeReturns this time with nanoseconds subtracted from it. common operator fun minus(seconds: Seconds): OffsetTimeReturns this time with seconds subtracted from it. common operator fun minus(duration: Duration): OffsetTimeReturns this time with duration subtracted from it. |
| plus | common operator fun plus(duration: Duration): OffsetTimecommon operator fun plus(hours: Hours): OffsetTimeReturns this time with hours added to it. common operator fun plus(microseconds: Microseconds): OffsetTimeReturns this time with microseconds added to it. common operator fun plus(milliseconds: Milliseconds): OffsetTimeReturns this time with milliseconds added to it. common operator fun plus(minutes: Minutes): OffsetTimeReturns this time with minutes added to it. common operator fun plus(nanoseconds: Nanoseconds): OffsetTimeReturns this time with nanoseconds added to it. common operator fun plus(seconds: Seconds): OffsetTimeReturns this time with seconds added to it. common operator fun plus(duration: Duration): OffsetTimeReturns this time with duration added to it. |
| roundedDownTo | common fun OffsetTime.roundedDownTo(unit: TimeUnit): OffsetTimeReturns this time, rounded down to match the precision of a given unit. |
| roundedDownToNearest | common fun OffsetTime.roundedDownToNearest(increment: Hours): OffsetTimeReturns this time, rounded down to the nearest hour that satisfies the increment. common fun OffsetTime.roundedDownToNearest(increment: Microseconds): OffsetTimeReturns this time, rounded down to the nearest microsecond that satisfies the increment. common fun OffsetTime.roundedDownToNearest(increment: Milliseconds): OffsetTimeReturns this time, rounded down to the nearest millisecond that satisfies the increment. common fun OffsetTime.roundedDownToNearest(increment: Minutes): OffsetTimeReturns this time, rounded down to the nearest minute that satisfies the increment. common fun OffsetTime.roundedDownToNearest(increment: Nanoseconds): OffsetTimeReturns this time, rounded down to the nearest nanosecond that satisfies the increment. common fun OffsetTime.roundedDownToNearest(increment: Seconds): OffsetTimeReturns this time, rounded down to the nearest second that satisfies the increment. |
| roundedTo | common fun OffsetTime.roundedTo(unit: TimeUnit): OffsetTimeReturns 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 OffsetTime.roundedToNearest(increment: Hours): OffsetTimeReturns 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 OffsetTime.roundedToNearest(increment: Microseconds): OffsetTimeReturns 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 OffsetTime.roundedToNearest(increment: Milliseconds): OffsetTimeReturns 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 OffsetTime.roundedToNearest(increment: Minutes): OffsetTimeReturns 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 OffsetTime.roundedToNearest(increment: Nanoseconds): OffsetTimeReturns 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 OffsetTime.roundedToNearest(increment: Seconds): OffsetTimeReturns 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 OffsetTime.roundedUpTo(unit: TimeUnit): OffsetTimeReturns this time, rounded up to match the precision of a given unit. |
| roundedUpToNearest | common fun OffsetTime.roundedUpToNearest(increment: Hours): OffsetTimeReturns this time, rounded up to the nearest hour that satisfies the increment. common fun OffsetTime.roundedUpToNearest(increment: Microseconds): OffsetTimeReturns this time, rounded up to the nearest microsecond that satisfies the increment. common fun OffsetTime.roundedUpToNearest(increment: Milliseconds): OffsetTimeReturns this time, rounded up to the nearest millisecond that satisfies the increment. common fun OffsetTime.roundedUpToNearest(increment: Minutes): OffsetTimeReturns this time, rounded up to the nearest minute that satisfies the increment. common fun OffsetTime.roundedUpToNearest(increment: Nanoseconds): OffsetTimeReturns this time, rounded up to the nearest nanosecond that satisfies the increment. common fun OffsetTime.roundedUpToNearest(increment: Seconds): OffsetTimeReturns this time, rounded up to the nearest second that satisfies the increment. |
| toJavaOffsetTime | jvm fun OffsetTime.toJavaOffsetTime(): OffsetTimeConverts this time to an equivalent Java OffsetTime. |
| toNSDateComponents | darwin fun OffsetTime.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-04:00 or 02:30Z. |
| truncatedTo | common fun OffsetTime.truncatedTo(unit: TimeUnit): OffsetTimeReturns this time, rounded down to match the precision of a given unit. |