I din't find good answer how to easy calculate timezone offset for given point of time in Scala/Java.
Given:
Requirements: calculate offset for particular date in timezone 1, required to move this date to timezone 2.
Example:
datetime = 2017-10-23 00:00:00 in America/Los_Angeles timezone 1,
timezone 2 = Europe/Paris
Offset should equal +9, it can be used to move date from timezone 1 to timezone 2.
Wouldn't this do it?
import java.time.{LocalDateTime, ZoneId}
import java.time.temporal.ChronoUnit
val dateOfInterest = LocalDateTime.parse("2020-02-02T12:00")
ChronoUnit.HOURS.between(dateOfInterest.atZone(ZoneId.of("Europe/Paris"))
                        ,dateOfInterest.atZone(ZoneId.of("America/Los_Angeles")))
//res0: Long = 9
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With