I have a DateTime field which shows proper time on UI, I know behind the scene it is GMT format. However I would like to populate same format as it displays on UI in a text field along with some text.
Yes, formula is not valid for this requirement, so I used trigger to update the text field. date.format() is the savior.
String timeZone = UserInfo.getTimeZone().getID(); Datetime dateGMT = info.Info_Session_Date__c; Datetime dateTimeValue = Datetime.valueOf(dateGMT); string convertedString = dateTimeValue.format();