tags:

views:

84

answers:

2

I am porting some of our app from c# to java. Some data objects get xml serialized and stored for later use. The built in .net xml serialization automatically saves DateTime properties in the format below:

2009-05-11T16:47:08.6033346-04:00

How can I get this into a Date object in Java? I read that the date format is ISO 8601 which labled as SortableDateTime in the MSDN documentation.

Thanks!

+1  A: 

parseDateTime?

eed3si9n
+1  A: 

Use the following snippet:

import java.text.SimpleDateFormat;
import java.util.Date;


SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
Date d = sdf.parse("2009-05-11T16:47:08.6033346-04:00");
Chaos