To convert between time zones in Java, create a ZonedDateTime and call withZoneSameInstant(ZoneId). The result represents the same moment on the timeline, expressed as the local date and time in the target zone. Use the java.time package (Java 8 and later) and avoid the legacy Date, Calendar and SimpleDateFormat classes.
Always use region-based IDs such as Europe/Paris or Asia/Kolkata, not fixed offsets or three-letter abbreviations like IST, because only region IDs follow daylight saving rules.
| Class | What it holds | Typical use |
|---|---|---|
ZoneId | A region such as America/New_York, with its daylight saving rules | Choosing a zone |
ZoneOffset | A fixed offset from UTC such as +05:30 | Parsing and storing exact offsets |
ZonedDateTime | Date, time and a ZoneId | Calendar-aware conversion and display |
OffsetDateTime | Date, time and a fixed offset | Databases and APIs |
Instant | A point on the UTC timeline | Storing and comparing moments |
ZoneId.getAvailableZoneIds() lists the supported region IDs, which come from the IANA time zone database bundled with the JDK.
All four values are the same instant. Notice that India is offset by 5 hours 30 minutes, so conversion must not assume whole-hour offsets.
These two methods are easy to confuse and give different results.
withZoneSameInstant keeps the moment and changes the clock reading, which is what you want for conversion. withZoneSameLocal keeps the clock reading and changes the moment, which is only correct when you are attaching the right zone to a local time that was entered without one.
A LocalDateTime has no zone, so you must say which zone it belongs to before converting.
The date changes in Sydney, a reminder that conversion can cross midnight.
When clocks move forward, some local times do not exist. When they move back, some local times occur twice. ZonedDateTime resolves these cases for you.
For schedules, store the local time and the region ID so rules apply correctly. For events that happened at an exact moment, store an Instant.
Instant or an ISO-8601 string ending in Z.ZoneId only for display, and keep the user's zone as a separate setting.ZoneId.systemDefault() for server logic, because the default depends on the machine.Clock in code that calls now(), so tests can fix the time.ZoneOffset is a fixed difference from UTC, such as +05:30. ZoneId is a region with rules that can change the offset during the year, such as America/New_York.
Use ZonedDateTime.now(ZoneId.of("Asia/Tokyo")), or Instant.now().atZone(zone). Both read the current instant and apply the zone.
Call date.toInstant() and then atZone(zone). For the reverse, use Date.from(zonedDateTime.toInstant()).
They are ambiguous. IST can mean India, Israel or Irish Standard Time, and CST can mean US Central or China Standard Time. Region IDs are unambiguous.
Convert time zones in Java with ZonedDateTime.withZoneSameInstant(ZoneId), using region IDs from the IANA database. Store moments as UTC Instant values, attach a zone only for display or scheduling, and handle daylight saving gaps and overlaps with the ZonedDateTime resolution rules.