You need to sign in to do that
Don't have an account?
Adam Howarth
String date (yyyy-MM-ddTHH:mm:ss.SSSZ) into date object
Hey guys,
I have got this working but it looks horrible!
Is there anything more efficient or out of the box to convert a string in the format yyyy-MM-ddTHH:mm:ss.SSSZ to a date object.
Tried parsing after removing the time, valueOf etc.
Heres my code:
// Parses the returned datetime (yyyy-MM-ddTHH:mm:ss.SSSZ)
private date ParseDateTime(string value)
{
String[] dateAndTime = value.split('T');
String[] dateParts = dateAndTime[0].split('-');
return date.newinstance(Integer.valueOf(dateParts[0]), Integer.valueOf(dateParts[1]),Integer.valueOf(dateParts[2]));
}
Cheers,
Adam
Hi,
Try below code :-
I dont think you read the question properly.
I am well aware of converting a date time to a date.
The problem is it is a DateTime string in the format described in the title.
So I am calling my method like this:
ParseDateTime('2012-03-08T10:51:12.421Z');
Try this.