Using the Calendar Class to Display Current Time in Different Time Zones : TimeZone « Development Class « Java






Using the Calendar Class to Display Current Time in Different Time Zones

   

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));

  }
}
//Time in New York: 11:51

   
    
    
  








Related examples in the same category

1.Format TimeZone in z (General time zone) format like EST.
2.Format TimeZone in zzzz format Eastern Standard Time.
3.Format TimeZone in Z (RFC 822) format like -8000.
4.Display Available Time Zones
5.Get all available timezones
6.Convert time between timezone
7.TimeZone.getTimeZone("America/New_York")
8.TimeZone.getTimeZone("Europe/Paris")
9.TimeZone.getTimeZone("Asia/Tokyo")
10.Converting Times Between Time Zones
11.Getting the Current Time in Another Time Zone
12.Get current TimeZone using Java Calendar
13.Create a Calendar object with the local time zone and set the UTC from japanCal
14.Get the time in the local time zone
15.Timezone conversion routines
16.Convert the date to the given timezone