Get the display name for a Timezone

Problem:

You want to get a localized display name for a time zone.

Solution:

You can get a display name for a TimeZone in Java very easily by specifying a locale in the getDisplayName method.

 

To get a display name for Canada/Mountain in Japanese:

//Get a locale for japanese in Japan
Locale jp = new Locale("ja","JP");
//Get a TimeZone for the id Canada/Mountain
TimeZone tz = TimeZone.getTimeZone("Canada/Mountain");
//output the display name
System.out.println(tz.getDisplayName(jp));

 


The output:

山地標準時