Tutorial :How to read .net xml serialized datetimes from java?



Question:

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!


Solution:1

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");  


Solution:2

parseDateTime?


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »