Convert datetime to GMT format in apex
Here I am going to provide two examples of datetime conversion that use current datetime.
1. Conversion in local time zone
String formatedInLocalTimeZone = Datetime.now().format('yyyy-MM-dd\'T\'HH:mm:ss\'Z\''); System.debug('In Local TimeZone^^^'+formatedInLocalTimeZone);Output:
2. Conversion in GMT
String formatedInGMT = Datetime.now().formatGMT('yyyy-MM-dd\'T\'HH:mm:ss\'Z\''); System.debug('In GMT^^^'+formatedInGMT);Output:
Hope you like this post, for any feedback or suggestions please feel free to comment. I would appreciate your feedback and suggestions.
Happy Coding...:)
Thank you.
0 Comments
Post a Comment