Answers for "java java.time.ZoneId to java.util.TimeZone"

0

java java.time.ZoneId to java.util.TimeZone

package com.javabrahman.java8.time;
import java.time.ZoneId;
import java.util.TimeZone;
public class ZoneIdToTimeZone {
  public static void main(String args[]) {
 
    //Convert system's 'default' java.time.ZoneId to java.util.TimeZone
    TimeZone timeZone = TimeZone.getTimeZone(ZoneId.systemDefault());
    System.out.println("TimeZone from system's default ZoneId: " + timeZone);
 
    //Convert custom java.time.ZoneId to java.util.TimeZone
    TimeZone timeZoneLA = TimeZone.getTimeZone(ZoneId.of("America/Los_Angeles"));
    System.out.println("TimeZone from custom 'LA' ZoneId: " + timeZoneLA);
  }
}
Posted by: Guest on May-19-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language