简体   繁体   中英

Java Simple Date format Conversion

If 2011-11-26T03:53:00.001-0800 is yyyy-MM-dd'T'HH:mm:ss.SSSZ

Then what is 2011-11-26T03:53:00.001-08:00

Hope it explains everything what i need...

Ok, i've found a solution to your problem.

" The solution is possibly to use the data type converter in JAXB, since JAXB must be able to parse ISO8601 date string according to the XML Schema specification. javax.xml.bind.DatatypeConverter.parseDateTime("1999-01-01T23:59:59.999-08:00") will give you a Calendar object and you can simply use getTime() on it, if you need a Date object. "

This is the link where i found the above answer.

You can simply use it like this:

Calendar cl = javax.xml.bind.DatatypeConverter.parseDateTime("1999-01-01T23:59:59.999-08:00");
System.out.println(cl.getTime());

Hope this helps. Cheers!

yyyy-MM-dd'T'HH:mm:ss.SSSz

From RFC822 Timezone to General timezone. See this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM