Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Date; import java.util.GregorianCalendar; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; public class Main { /** * Parse an xs:dateTime value in "2009-05-21T14:52:18-07:00" format (with the timezone). * * @param timestamp * The xs:dateTime * @return The converted date * @throws DatatypeConfigurationException * For errors. */ public static Date parseXmlDateTimeWithZone(String timestamp) throws DatatypeConfigurationException { DatatypeFactory datatypeFactory = DatatypeFactory.newInstance(); XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(timestamp); GregorianCalendar gregorianCalendar = xmlGregorianCalendar.toGregorianCalendar(); return gregorianCalendar.getTime(); } }