Create TimeZone

ReturnMethodSummary
static TimeZonegetDefault()Gets the default TimeZone for this host.
static TimeZonegetTimeZone(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
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.