I want to parse below date in Java,
2012-11-29T09:15:00.002-08:00
Which date format I have to use to parse it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Actually, this format is an XSD date format, and the simplest way to parse it (without any use of an external library) is to use
DataTypeConverter.parseDateTime(String lexicalXSDDateTime)in thejavax.xml.bind package. This will return you ajava.util.Calendarobject, which you can retrieve aDateusingCalendar.getTime().Alternatively, there are solutions on SO that speaks about the same formatting, such as: What’s the best way to parse an XML dateTime in Java?
enter link description here.
I hope this helps.
Using Date format as
"yyyy-MM-dd'T'HH:mm:ss.SSSz"E.g.: