Get TimeZone by name(America/New_York)


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

  }
}

Output:


Time in New York: 11:51

import java.util.Calendar;
import java.util.TimeZone;

public class Main {

  public static void main(String[] args) {
    Calendar calParis = Calendar.getInstance();

    calParis.setTimeZone(TimeZone.getTimeZone("Europe/Paris"));
    System.out.println("Time in Paris: " + calParis.get(Calendar.HOUR_OF_DAY) + ":"
        + calParis.get(Calendar.MINUTE));

  }
}

Output:


Time in Paris: 17:51

import java.util.Calendar;
import java.util.TimeZone;

public class Main {

  public static void main(String[] args) {
    Calendar calTokyo = Calendar.getInstance();

    calTokyo.setTimeZone(TimeZone.getTimeZone("Asia/Tokyo"));

    System.out.println("Time in Tokyo: " + calTokyo.get(Calendar.HOUR_OF_DAY) + ":"
        + calTokyo.get(Calendar.MINUTE));
  }
}

Output:


Time in Tokyo: 1:51
Home 
  Java Book 
    Runnable examples  

Date TimeZone:
  1. Available Time Zones
  2. Current TimeZone
  3. Canoncial Timezone string
  4. Convert time between timezone
  5. Convert Current Time to Another Time Zone
  6. Convert Japan date and time to your local timezone
  7. Get TimeZone by name(America/New_York)