Java maintenance and ecosystem

Translate a legacy date at an explicit zone

One instant can map to different calendar dates. The conversion requires business-zone semantics.

Formal Syntax & Structure

java syntaxjava
Date.toInstant().atZone(zone).toLocalDate()

Working Example

Example Snippetjava
public class Main {    public static void main(String[] args) throws Exception {        var date=java.util.Date.from(java.time.Instant.parse("2024-01-01T00:30:00Z"));        System.out.println(date.toInstant().atZone(java.time.ZoneOffset.UTC).toLocalDate());        System.out.println(date.toInstant().atZone(java.time.ZoneId.of("America/New_York")).toLocalDate());    }}
Java Reference