One of the external APIs we use requires
"YYYY-MM-DDThh:mm:ssTZD"
format to be passed in
XMLGregorianCalendar
object. I am not sure if there is anything in Java that supports "T"
. I was wondering, if a date can be parsed into above format in Java? An example of a valid date they have provided
is
"2009-07-16T19:20:30-05:00"
............
Update:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZ");
GregorianCalendar gc = new GregorianCalendar();
String dateString = sdf.format(gc.getTime());
gc.setTime(sdf.parse(dateString));
XMLGregorianCalendar date2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
Output:
2014-04-17T13:11:30.000+01:00