3

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.

4

you can achieve it by replacing the Z with XXX.

Datetime sdf = Datetime.now();

system.debug(sdf.format('yyyy-MM-dd\'T\'HH:mm:ss.SSSXXX'));

The result was:

2015-05-20T20:28:23.203+02:00

This is documented here

1
  • 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.