0

I wanna convert String date and time to Apex date and time.

2016-12-23T07:26:33+0000 => DateTime Of apex.

How to convert ?

2

2 Answers 2

1

I think de-serializing it to a DateTime class should work fine.

System.debug(JSON.deserialize('"2016-12-23T07:26:33+0000"', DateTime.class));

Just make sure that the date is enclosed in double quotes i.e "<DATE>"

1

Try this one

String dateTimeInString = '2016-12-23T07:26:33+0000';

DateTime acceptableDateTime = DateTime.Valueof(dateTimeInString.replace('T', ' ')); 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .