SimpleDateFormat and 2013-01-17T00: 00: 00-06: 00

What format will SimpleDateFormat use to parse incoming dates that look like this: "2013-01-17T00: 00: 00-06: 00"?

+3


source to share


5 answers


The format will look like yyyy-MM-dd'T'HH:mm:ssX



+1


source


This format should work:



"yyyy-MM-dd'T'HH:mm:ssXXX"

      

+3


source


You must strip the last colon to align it with the java zone information format "-0600"

.

Try the following:

String str = "2013-01-17T00:00:00-06:00";
new SimpleDataFormat("yyyy-MM-dd'T'hh:mm:ssZ").parse(str.replaceAll(":(..)$", "$1"));

      

+1


source


YYYY-MM-dd'T'HH: mm: SSZ

Send this link: http://www.w3.org/TR/NOTE-datetime

0


source


SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd'T'HH: mm: ssZ"); System.out.println (sdf.format (new GregorianCalendar (). GetTime ()));

This is not enough?

0


source







All Articles