Converting code to utilize the TimeZone class for easier maintainability. For now, I'm stuck relying on a pseudo-timezone field on contacts (c.Time_Zone__c below) to make the determination and setting a string variable to what I think are correct timeZoneIdStrings. I would like to use that string to instantiate a new TimeZone object and then call the getDisplayName method on the object. Is the timeZoneIdString parameter not actually of type String? If not, is there a way to get the necessary Id?
String tz;
if(c.Time_Zone__c == 'Eastern'){
tz = 'America/New_York';
} else if(c.Time_Zone__c == 'Central'){
tz = 'America/Chicago';
} else if(c.Time_Zone__c == 'Mountain'){
tz = 'America/Denver';
} else if(c.Time_Zone__c == 'Pacific'){
tz = 'America/Los_Angeles';
}
TimeZone tzone = TimeZone.getTimeZone(tz);
timeZoneDisplay = tzone.getDisplayName();
TimeZone
?TimeZone
.timezone
that I was missing. Thank you for your help.