Search code examples
javajava-8zoneddatetime

Does Java 8's ZonedDateTime take into account daylight savings when converting?


I have the following code below:

ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(
            this.start.toLocalDateTime(), ZoneOffset.UTC,
            ZoneOffset.systemDefault());

The this.start is from a java.sql.Timestamp. I am explicitly converting from UTC here to the system's local offset, will this be smarty enough to take into account daylight savings?


Solution

  • ZonedDateTime takes daylight savings into account. That's what differs it from LocalDateTime. Well, that and timezone information.