java java time zoneid to java util timezone

Solutions on MaxInterview for java java time zoneid to java util timezone by the best coders in the world

showing results for - "java java time zoneid to java util timezone"
Imen
10 Apr 2019
1package com.javabrahman.java8.time;
2import java.time.ZoneId;
3import java.util.TimeZone;
4public class ZoneIdToTimeZone {
5  public static void main(String args[]) {
6 
7    //Convert system's 'default' java.time.ZoneId to java.util.TimeZone
8    TimeZone timeZone = TimeZone.getTimeZone(ZoneId.systemDefault());
9    System.out.println("TimeZone from system's default ZoneId: " + timeZone);
10 
11    //Convert custom java.time.ZoneId to java.util.TimeZone
12    TimeZone timeZoneLA = TimeZone.getTimeZone(ZoneId.of("America/Los_Angeles"));
13    System.out.println("TimeZone from custom 'LA' ZoneId: " + timeZoneLA);
14  }
15}
16