Package-level declarations

Properties

Link copied to clipboard
val LocalTime.asDuration: Duration

Returns this object as kotlin.time.Duration

Link copied to clipboard
val Duration.asLocalTime: LocalTime

Convert this duration to LocalTime. If this duration is larger than 24 hours, clock will wrap around.

Link copied to clipboard

Returns a new ZonedDateTime with it's day of week set to the first using this's ZonedDateTime.zone

Link copied to clipboard
Link copied to clipboard
val Instant.Companion.EPOCH: Instant

Returns an Instant of Jan 1st 1970 00:00:00.000 UTC.

Link copied to clipboard
val LocalTime.hourAs12H: Int

Get hour in am/pm format (just the number)

Link copied to clipboard
val LocalTime.isPM: Boolean

Whether the hours cross the PM threshold (hour >= 12)

Link copied to clipboard

Returns true if this is on the same day as ZonedDateTime.now using local time zone

Link copied to clipboard

Returns true if this is a valid time string

Link copied to clipboard
val LocalDate.lengthOfMonth: Int

Computes the length of the current month of LocalDate in days

val LocalDateTime.lengthOfMonth: Int

Computes the length of the current month of LocalDateTime in days

Computes the length of month of this zoned datetime.

Link copied to clipboard
val LocalTime.Companion.MAX: LocalTime

23:59:59

Link copied to clipboard

Returns a new ZonedDateTime with this's time set to midnight.

Link copied to clipboard
val LocalTime.Companion.MIN: LocalTime

00:00:00

Link copied to clipboard
val LocalTime.totalMinutes: Double
Link copied to clipboard
val LocalTime.totalSeconds: Int

Get the amount of seconds since midnight. Convenient for storing LocalTime as an Int value

Link copied to clipboard
val DayOfWeek.value: Int

ISO8601 value of the day of the week, from 1 (Monday) to 7 (Sunday).

Functions

Link copied to clipboard
fun LocalTime.add(hours: Int = 0, minutes: Int = 0, seconds: Int = 0): LocalTime

Add specified number of hours, minutes, or seconds to this time. If the argument is not specified, 0 will be added. If the resulting value is bigger than 23:59:59, the value will be wrapped (e.g. to 00:00:00)

Link copied to clipboard
fun LocalDateTime.asMidnight(): LocalDateTime

Returns a new LocalDateTime set to the midnight.

Link copied to clipboard
fun LocalDateTime.asStartOfMonth(): LocalDateTime

Returns a new LocalDateTime that is set to the first day of month and 00:00:00.000 of the month of this.

Link copied to clipboard
fun LocalDateTime.asStartOfWeek(zone: TimeZone): LocalDateTime

Returns a new LocalDateTime that is set to DayOfWeek.MONDAY and 00:00:00.000 of the week of this.

Link copied to clipboard
fun LocalDateTime.asStartOfYear(): LocalDateTime

Returns a new LocalDateTime that is set to the first day of year and 00:00:00.000 of the year of this.

Link copied to clipboard
fun LocalTime.asString(use12h: Boolean = false, addSecondsIfZero: Boolean = false): String

Same as toString but gives you a choice on whether to use 12H scheme. toString uses asString(false).

Gets the DayOfWeek.getDisplayName of this using system default locale

Formats this using formatter

fun Month.asString(textStyle: TextStyle = TextStyle.FULL, locale: Locale = Locale.getDefault()): String

Returns a string representation of this using specified textStyle and locale

Link copied to clipboard
fun LocalTime.Companion.asTimeNumber(value: Int): String

Represents this numeric value as if it is a number on the clock Examples:

Link copied to clipboard
fun LocalTime.atDate(date: LocalDate): LocalDateTime

Create a new LocalDateTime using given date

Link copied to clipboard
fun LocalDate.atTime(time: LocalTime): LocalDateTime

Create a LocalDateTime with the specified time

Link copied to clipboard
infix fun LocalTime.distanceInSeconds(to: LocalTime): Int
Link copied to clipboard
infix fun LocalTime.distanceTo(other: LocalTime): LocalTime

Calculate distance to the other between LocalTime.MIN and LocalTime.MAX

Link copied to clipboard
operator fun LocalTime.get(index: Int): Int

Get either the hour or minute or second value of this time. Values more than 2 will throw an IndexOutOfBoundsException

Link copied to clipboard
operator fun LocalTime.Companion.invoke(duration: Duration): LocalTime

Create a new LocalTime from duration. If the duration is larger than 24 hours, it will wrap around

Link copied to clipboard

Returns tru if this calendar is set to current month, computed using local date and timezone of the original calendar.

Link copied to clipboard

Returns tru if this calendar is set to current year, computed using local date and timezone of the original calendar

Link copied to clipboard
fun LocalTime.Companion.isValid(time: String): Boolean

Returns true if time is a valid time string

Link copied to clipboard
fun Month.length(year: Int): Int

Finds the length of a given month based on the year, in days.

Link copied to clipboard
operator fun LocalTime.minus(other: LocalTime): LocalTime

Subtract other from LocalTime

Link copied to clipboard
fun LocalDateTime.minusDays(days: Int, zone: TimeZone): LocalDateTime

Subtracts a specified number of days from this.

Returns a new Instant with given number of days subtracted

Link copied to clipboard
fun LocalDateTime.minusMonths(months: Int, zone: TimeZone): LocalDateTime

Subtracts a specified number of months from this. Returns a new LocalDateTime

Link copied to clipboard
fun LocalDate.Companion.now(zone: TimeZone): LocalDate

Get the current date using provided zone.

fun LocalDateTime.Companion.now(zone: TimeZone): LocalDateTime

Creates a new Instant and converts it to LocalDateTime

fun LocalTime.Companion.now(zone: TimeZone): LocalTime

Get the current time using provided zone.

Link copied to clipboard
fun LocalTime.Companion.ofInt(hms: Int): LocalTime

Parse a new time object using the int representation of it.

Link copied to clipboard
fun LocalTime.Companion.ofMillis(millis: Int): LocalTime

Create a time from milliseconds since midnight. millis is NOT a timestamp

Link copied to clipboard
fun LocalTime.Companion.ofSeconds(seconds: Int): LocalTime

Get current time value using specified seconds since midnight seconds is NOT a timestamp

Link copied to clipboard
fun LocalDateTime.onSameDay(other: LocalDateTime): Boolean

Returns tru if this is on the same day as other. Ignores time, but considers year and month.

Link copied to clipboard

Whether this is on the same day as other, using ZoneId of this and other. It's important that if the ZonedDateTime.zones are different, the values can still be on the same day

Link copied to clipboard

Returns true if this is on the same day as other, not considering time zones

Link copied to clipboard
fun LocalTime.Companion.parseAs12H(s: String): LocalTime

example: 12:45:00, 4:30, 7:00 AM, 24 or 12h format, word separator is " ". On a value that is not a valid time, will throw.

Link copied to clipboard
fun LocalTime.Companion.parseOrNull(s: String): LocalTime?

Parse s as time serialized using LocalTime.toString and return null if it fails.

Link copied to clipboard
operator fun Instant.plus(time: LocalTime): Instant

Adds a specified time to this. Returns a new Instant

operator fun LocalTime.plus(other: LocalTime): LocalTime

Create a new time with the result of adding LocalTime to other

fun LocalDateTime.plus(value: Int, unit: DateTimeUnit, zone: TimeZone): LocalDateTime

Adds a given value to the this, converting it to Instant for the addition.

Link copied to clipboard
fun LocalDate.plusDays(days: Int): LocalDate

Returns a new LocalDate with specified days added

fun LocalDateTime.plusDays(days: Int, zone: TimeZone): LocalDateTime

Adds a specified number of days to this.

Returns a new Instant with given number of days added

Link copied to clipboard
fun LocalDateTime.plusMonths(months: Int, zone: TimeZone): LocalDateTime

Adds a specified number of months to this. Returns a new LocalDateTime

Link copied to clipboard

Resets this to the last millisecond of the day.

Link copied to clipboard

Resets this to the last day of the month and the last millisecond of the day

Link copied to clipboard

Resets this calendar to the start of the day. Modifies the original object.

Link copied to clipboard

Resets this to the start of the month and midnight.

Link copied to clipboard

Sets field to its maximum value

Link copied to clipboard

Resets a given Calendar to the start of the day. Modifies the original object.

Link copied to clipboard

Sets field to its minimum value

Link copied to clipboard
fun Iterable<DayOfWeek>.sortedByLocale(locale: Locale = Locale.getDefault()): List<DayOfWeek>

Sorts DayOfWeeks according to the locale. I.e. will affect the first value (Monday / Sunday etc.)

Link copied to clipboard
fun LocalTime?.takeIfNotZero(): LocalTime?

If this is LocalTime.MIN return null, this otherwise

Link copied to clipboard
fun Date.toCalendar(timeZone: TimeZone = TimeZone.getDefault(), locale: Locale = Locale.getDefault()): Calendar

Creates a new Calendar using this as the date.

fun Long.toCalendar(timeZone: TimeZone = TimeZone.getDefault(), locale: Locale = Locale.getDefault()): Calendar

Creates a new Calendar using this as the time in milliseconds.

Link copied to clipboard
fun LocalTime.toInt(): Int

Returns an integer that represents this time, like a string, but without the ":"

Link copied to clipboard
fun String?.toLocalTimeOrNull(): LocalTime?

Try to parse this as LocalTime or return null if it fails

Link copied to clipboard
fun Iterable<LocalTime?>.totalDuration(): Duration

Compute total asDuration of all items in the collection

@JvmName(name = "totalDurationSequence")
fun Sequence<LocalTime?>.totalDuration(): LocalTime

Compute total asDuration of all items in the sequence

Link copied to clipboard

Creates a new ZonedDateTime using this Instant and a given zoneId

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

Returns the same time with all of nanos, seconds and minutes set to 0

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

Returns the same time with LocalTime.nanosecond set to 0.

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

Returns the same time with both nanos and seconds set to 0.

Link copied to clipboard
fun LocalTime.Companion.with(hours: Int = 0, minutes: Int = 0, seconds: Int = 0): LocalTime

Create a new time using specified hours, minutes, or seconds If you specify a value bigger than the initial, the remainder will spill into the next value. If you specify a value bigger than LocalTime.MAX, it will wrap around. Examples:

Link copied to clipboard
fun LocalDate.withDayOfMonth(day: Int): LocalDate

Returns a new LocalDate with the day of month set to the specified day

fun LocalDateTime.withDayOfMonth(day: Int): LocalDateTime

Returns a new LocalDateTime with the given day of month and everything else of this.

Link copied to clipboard
fun LocalDateTime.withMonth(month: Month): LocalDateTime

Returns a new LocalDateTime with the given month and everything else of this.

Link copied to clipboard
fun LocalDateTime.withNextDayOfWeek(dayOfWeek: DayOfWeek, zone: TimeZone): LocalDateTime

Returns a new LocalDateTime that has the date adjusted to the date with the given next dayOfWeek. If the date is already on the given dayOfWeek, returns a date a week later.

Link copied to clipboard
fun LocalDateTime.withPreviousOrSameDayOfWeek(dayOfWeek: DayOfWeek, zone: TimeZone): LocalDateTime

Returns a new LocalDateTime that has either the same (if this has the same day of week as dayOfWeek) or the previous dayOfWeek.

Link copied to clipboard
fun LocalDateTime.withTime(time: LocalTime, nanos: Int = nanosecond): LocalDateTime

Create a new LocalDateTime with the given time and nanos Preserves nanos of previous time

fun ZonedDateTime.withTime(time: LocalTime): ZonedDateTime

Sets this's time to time. Returns a new ZonedDateTime