1package com.javabrahman.java8.time;
2import java.time.ZoneId;
3import java.util.TimeZone;
4public class TimeZoneToZoneId {
5 public static void main(String args[]) {
6
7 //Converting system's 'default' java.util.TimeZone to java.time.ZoneId
8 ZoneId zoneId = TimeZone.getDefault().toZoneId();
9 System.out.println("ZoneId from default system TimeZone: " + zoneId);
10
11 //Converting custom defined java.util.TimeZone to java.time.ZoneId
12 TimeZone timeZoneLA = TimeZone.getTimeZone("America/Los_Angeles");
13 ZoneId zoneIdLA = timeZoneLA.toZoneId();
14 System.out.println("ZoneId from custom 'LA' TimeZone: " + zoneIdLA);
15
16 }
17}
18