I'm trying to format the date into specific format in Apex class, Desired result: 2015-05-19T18:52:30.937-07:00

By using SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); what I get is 2015-05-19T18:52:30.937-0700

I would like to know if the desired result (....-07:00 instead ....-0700) can be achieved without doing string manipulation, which is my last option.

Any help would be greatly appreciated.


you can achieve it by replacing the Z with XXX.

Datetime sdf = Datetime.now();


The result was:


This is documented here

  • Archieve haha. Somewhere between archive and achieve. – Adrian Larson May 20 '15 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.