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

To display time in a specific time zone we can use the Calendar class. After it has been created we set the time zone on the instance using the method setTimeZone. It is really all that is to it, after that we can just query the instance for hours and minutes as in the code example below where time in three major cities around the world is displayed.

Here is what the output looked like when the example above was run:

To display a list of available time zone IDs, please see this link:

Display Available Time Zones

Search for more Java info on this site here:
Custom Search

Please type any questions here.