Create TimeZone
static TimeZone getDefault()
- Gets the default TimeZone for this host.
static TimeZone getTimeZone(String ID)
- Gets the TimeZone for the given ID.
import java.util.Calendar;
import java.util.TimeZone;
public class Main {
public static void main(String[] args) {
Calendar calNewYork = Calendar.getInstance();
calNewYork.setTimeZone(TimeZone.getTimeZone("America/New_York"));
System.out.println("Time in New York: " + calNewYork.get(Calendar.HOUR_OF_DAY) + ":"
+ calNewYork.get(Calendar.MINUTE));
}
}
The output:
Time in New York: 16:50