title: Java SimpleDateFormat for YYYY-MM-DDThh:mm:ssTZD
body: <p>One of the external APIs we use requires</p>
  
  <p><code>"YYYY-MM-DDThh:mm:ssTZD"</code></p>
  
  <p>format to be passed in </p>
  
  <p><code>XMLGregorianCalendar</code></p>
  
  <p>object. I am not sure if there is anything in Java that supports <code>"T"</code>. I was wondering, if a date can be parsed into above format in Java? An example of a valid date they have provided
  is</p>
  
  <p><code>"2009-07-16T19:20:30-05:00"</code>............</p>
  
  <pre><code> 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);
  </code></pre>
  
  <p>Output:</p>
  
  <p>2014-04-17T13:11:30.000+01:00</p>