I wanted to display CST instead (America/Chicago) in the view. I have a TimeZoneSidKey But not sure how to get the Short Name (CST) of the timezone by using the TimeZoneSidKey .
1 Answer
@RKCY Is your view custom or out of the box? Salesforce Timezone class won't provide you what you are looking for and rightfully so because short names are different depending upon the dates. They show CDT vs CST (Daylight Time vs Standard Time). Also, America/Phoenix has two different timezones depending on which day you are referencing to. Static map of values wont work either.
Here's a custom code
DateTime dtMydateTime = System.now();
String DATE_TIME_FORMAT_HOUR_MIN_SEC = 'MM/dd/yyyy hh:mm:ss a z';
String strDateTimeWithTimezone = dtMydateTime.format(DATE_TIME_FORMAT_HOUR_MIN_SEC, UserInfo.getTimeZone().toString());
https://docs.oracle.com/javase/6/docs/api/java/util/TimeZone.html