Home Java LocalDateTime Methods atZone() Java LocalDateTime atZone() Method Definition In Java, dt.atZone(zone) combines a LocalDateTime with a ZoneId such as Asia/Kolkata. The result is a ZonedDateTime, which is a real moment on the timeline and knows its own offset.
In most cases the local date and time stay the same. The exception is a daylight saving gap, where the time does not exist, and Java moves it forward.
An instance method of java.time.LocalDateTime (since Java 8): call it on a LocalDateTime object. Add import java.time.LocalDateTime; at the top of your file.
Syntax Pass a ZoneId. Create one with ZoneId.of("Region/City").
LocalDateTime dt = LocalDateTime.of(2026, 3, 15, 10, 30);
ZonedDateTime india = dt.atZone(ZoneId.of("Asia/Kolkata")); // 2026-03-15T10:30+05:30[Asia/Kolkata] Call What it does dt.atZone(zone)The date-time with a zone. zdt.withZoneSameInstant(zone)The same moment as seen in another zone. zdt.toInstant()The exact moment, as an Instant. zdt.toLocalDateTime()Drops the zone, and gives back a LocalDateTime.
Use ZoneId.of("Asia/Kolkata") and not short names such as IST, which are unclear.
Library declarations // java.time.LocalDateTime
public ZonedDateTime atZone(ZoneId zone) Parameters Parameter Description zone (ZoneId)The time zone to use. It must not be null.
Return Value Return Value Description ZonedDateTimeThe date-time combined with the zone, with the correct offset worked out.
Important
The local time is not converted. To see the same moment in another zone, call withZoneSameInstant() on the result. Daylight saving time causes two special cases. In a gap (clocks go forward), the local time does not exist and is moved forward by the length of the gap. In an overlap (clocks go back), the time happens twice and the earlier offset is used. An unknown zone name throws a ZoneRulesException when you create the ZoneId.
Compare with Similar Methods Ways to give a date-time a zone or offset:
Java Examples 1. Add a zone 2. Convert zones 3. Gap and overlap Example 1 — Attach a Time Zone to a Date-Time Attach the India zone, and look at the offset and the real moment in UTC.
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
public class LdtAtZoneDemo {
public static void main(String[] args) {
LocalDateTime dt = LocalDateTime.of(2026, 3, 15, 10, 30);
ZonedDateTime india = dt.atZone(ZoneId.of("Asia/Kolkata"));
System.out.println("zoned: " + india);
System.out.println("offset: " + india.getOffset());
System.out.println("moment: " + india.toInstant());
}
} zoned: 2026-03-15T10:30+05:30[Asia/Kolkata]
offset: +05:30
moment: 2026-03-15T05:00:00Z How It Works A local date-time. 10:30 on 15 March 2026, with no zone.Add the zone. The result shows the local time, the offset +05:30, and the zone name in brackets.The offset. getOffset() gives the offset that applies on that date.The real moment. toInstant() shows the same moment in UTC: 5 hours 30 minutes earlier, at 05:00.Example 2 — Convert a Time from One Zone to Another It is 10:30 in Tokyo. Find out what time it is in New York at the same moment.
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
public class LdtAtZoneConvert {
public static void main(String[] args) {
LocalDateTime meeting = LocalDateTime.of(2026, 3, 15, 10, 30);
ZonedDateTime tokyo = meeting.atZone(ZoneId.of("Asia/Tokyo"));
ZonedDateTime newYork = tokyo.withZoneSameInstant(ZoneId.of("America/New_York"));
System.out.println("Tokyo: " + tokyo.toLocalDateTime());
System.out.println("New York: " + newYork.toLocalDateTime());
System.out.println("same moment: " + tokyo.toInstant().equals(newYork.toInstant()));
}
} Tokyo: 2026-03-15T10:30
New York: 2026-03-14T21:30
same moment: true How It Works Start in Tokyo. atZone() says that 10:30 is Tokyo time.Move to New York. withZoneSameInstant() keeps the moment and changes the clock reading.Thirteen hours back. On 15 March, New York is on daylight saving time, so it is 13 hours behind Tokyo. 10:30 becomes 21:30 on the previous day.Still one moment. The two Instant values are equal.Example 3 — See How Daylight Saving Time Is Handled In New York in 2026 the clocks went forward on 8 March and back on 1 November. Attach a zone to a time inside each change.
import java.time.LocalDateTime;
import java.time.ZoneId;
public class LdtAtZoneDst {
public static void main(String[] args) {
ZoneId newYork = ZoneId.of("America/New_York");
LocalDateTime gap = LocalDateTime.of(2026, 3, 8, 2, 30);
LocalDateTime overlap = LocalDateTime.of(2026, 11, 1, 1, 30);
System.out.println("gap: " + gap.atZone(newYork));
System.out.println("overlap: " + overlap.atZone(newYork));
System.out.println("normal: " + LocalDateTime.of(2026, 7, 4, 12, 0).atZone(newYork));
}
} gap: 2026-03-08T03:30-04:00[America/New_York]
overlap: 2026-11-01T01:30-04:00[America/New_York]
normal: 2026-07-04T12:00-04:00[America/New_York] How It Works A time that does not exist. At 02:00 on 8 March the clocks jump to 03:00, so 02:30 never happens.Gap: moved forward. Java moves the time ahead by the length of the gap, one hour, to 03:30. The offset is now -04:00.A time that happens twice. At 02:00 on 1 November the clocks go back to 01:00, so 01:30 appears twice.Overlap: the earlier one. Java picks the first 01:30, which is still on summer time, with the offset -04:00. The last line is an ordinary day in July, where nothing special happens.Frequently Asked Questions How do I convert a LocalDateTime to ZonedDateTime in Java? Use dt.atZone(ZoneId.of("Asia/Kolkata")), with the zone you need.
Does atZone() convert the time to that zone? No. It says that the local time is in that zone. To convert to another zone, use withZoneSameInstant().
What happens to a time that does not exist during daylight saving time? In a gap, the time is moved forward by the length of the gap, so 02:30 becomes 03:30.
Which time is chosen when a time happens twice? The earlier offset, which is the first of the two times.
How do I convert a LocalDateTime from one zone to another? Use dt.atZone(fromZone).withZoneSameInstant(toZone).toLocalDateTime().
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful
Helpful Share Copy link Suggestion