Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

I was wondering if there is an apex date or datetime function to format a date/time to the ISO formatted timestamp "2007-04-05T12:30-02:00" or would this have to be created by another means?


1 Answer

0 votes
by (32.1k points)

DateTime format (string dataFormat) or format(string dataFormat, string timezone) methods can be used in Apex. It accepts a dataFormat string, which corresponds to a Java simple date format. You will need to define the correct format for ISO 8601.

Do take into account the timezone of the DateTime. In the below example, I have used the GMT format to avoid the timezone offset.


Alternatively, you can use the JSON serializer.


To learn in-depth about Workflow in Salesforce, sign up for an industry based Salesforce Admin certification.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.5k answers


108k users

Browse Categories