Skip to Content

Get current TimeZone using Java Calendar

  1. /*
  2.   Get current TimeZone using Java Calendar
  3.   This example shows how to get current TimeZone using getTimeZone method
  4.   of Java Calendar class.
  5.  
  6. */
  7.  
  8. import java.util.Calendar;
  9. import java.util.TimeZone;
  10.  
  11. public class GetCurrentTimeZone {
  12.  
  13.   public static void main(String[] args) {
  14.    
  15.     //get Calendar instance
  16.     Calendar now = Calendar.getInstance();
  17.    
  18.     //get current TimeZone using getTimeZone method of Calendar class
  19.     TimeZone timeZone = now.getTimeZone();
  20.    
  21.     //display current TimeZone using getDisplayName() method of TimeZone class
  22.     System.out.println("Current TimeZone is : " + timeZone.getDisplayName());
  23.   }
  24. }
  25.  
  26. /*
  27. Typical output would be
  28. Current TimeZone is : Eastern Standard Time
  29. */