Adam S
07/09/2023, 11:05 AMephemient
07/09/2023, 11:19 AMephemient
07/09/2023, 11:24 AMlocalDateTime.toInstant(TimeZone.UTC).plus(duration).toLocalDateTime(TimeZone.UTC)
but it raises the question of why would you be doing these operations with a Local*
instead of an Instant
?Adam S
07/09/2023, 1:26 PMoperator fun LocalDate.plus(duration: Duration): LocalDate =
atStartOfDayIn(TimeZone.UTC).plus(duration).toLocalDateTime(TimeZone.UTC).date
operator fun LocalDateTime.plus(duration: Duration): LocalDateTime =
toInstant(TimeZone.UTC).plus(duration).toLocalDateTime(TimeZone.UTC)
Adam S
07/09/2023, 1:27 PMbut it raises the question of why would you be doing these operations with aI’m updating some Java time code. My experience in Java is that Instant is awkward and difficult to use, but maybe my prejudice doesn’t apply to a Kotlin Instant?instead of anLocal*
?Instant
ephemient
07/09/2023, 1:32 PMephemient
07/09/2023, 1:34 PMSam Stone
07/11/2023, 5:25 PMephemient
07/11/2023, 5:27 PMephemient
07/11/2023, 5:29 PMSam Stone
07/12/2023, 4:58 AMyou need ... ZonedDateTime (which kotlinx-datetime doesn't have) to actually perform most operations.
Adam S
07/12/2023, 5:02 AMjava.time
) or ZDT (if using java.time
) to perform most operationsephemient
07/12/2023, 8:56 AM