Welcome to Srini's blog

Tuesday, August 17, 2010

Get short timezone displayname -- Java

I think you are already familiar with timezones, Ofcourse its not mandatory. Here discussion is If you want to export timezone value into Excel(.xls/.CSV) by default long name will come(like Asia/Calcutta). If you want to save short name(like IST) try the following code.

String timeZoneStr = "Asia/Calcutta";
String shortDisplayName = TimeZone.getTimeZone(timeZoneStr).getDisplayName(false, TimeZone.SHORT);


Here first boolean param indicates daylight saving on/off and TimeZone.SHORT indicates a style specifier for getDisplayName() indicating a short name, such as "IST."

No comments:

Post a Comment