Java Date Time Java Java API
Class:
java.time.ZoneId
Methods:
public static ZoneId of(String zoneId,
Map<String,String> aliasMap)
Creates an instance of ZoneId using its ID and a map of aliases to supplement the standard zone IDs.
public static ZoneId of(String zoneId)
Creates an instance of ZoneId from the provided ID ensuring that the ID is valid and available for use.
Examples
package com.logicbig.example.zoneid;
import java.time.ZoneId; import java.util.HashMap;
public class OfExample {
public static void main(String... args) { HashMap<String, String> aliasMap = new HashMap<>(); aliasMap.put("EST", "America/New_York"); ZoneId zoneId = ZoneId.of("EST", aliasMap); System.out.println(zoneId); } }
OutputAmerica/New_York
package com.logicbig.example.zoneid;
import java.time.ZoneId;
public class OfExample2 {
public static void main(String... args) { ZoneId z = ZoneId.of("America/Phoenix"); System.out.println(z); } }
OutputAmerica/Phoenix
|