Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Unfortunately, the time zone formats available to <a href="http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html" rel="noreferrer">SimpleDateFormat</a> (Java 6 and earlier) are not <a href="https://en.wikipedia.org/wiki/ISO_8601" rel="noreferrer">ISO 8601</a> compliant. SimpleDateFormat understands time zone strings like "GMT+01:00" or "+0100", the latter according to <a href="http://www.ietf.org/rfc/rfc0822.txt" rel="noreferrer" title="STANDARD FOR THE FORMAT OF ARPA INTERNET TEXT MESSAGES">RFC # 822</a>.</p> <p>Even if Java 7 added support for time zone descriptors according to ISO 8601, SimpleDateFormat is still not able to properly parse a complete date string, as it has no support for optional parts.</p> <p>Reformatting your input string using regexp is certainly one possibility, but the replacement rules are not as simple as in your question:</p> <ul> <li>Some time zones are not full hours off <a href="https://en.wikipedia.org/wiki/Coordinated_Universal_Time" rel="noreferrer">UTC</a>, so the string does not necessarily end with ":00".</li> <li>ISO8601 allows only the number of hours to be included in the time zone, so "+01" is equivalent to "+01:00"</li> <li>ISO8601 allows the usage of "Z" to indicate UTC instead of "+00:00".</li> </ul> <p>The easier 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. <code>javax.xml.bind.DatatypeConverter.parseDateTime("2010-01-01T12:00:00Z")</code> will give you a <code>Calendar</code> object and you can simply use getTime() on it, if you need a <code>Date</code> object.</p> <p>You could probably use <a href="http://www.joda.org/joda-time/" rel="noreferrer">Joda-Time</a> as well, but I don't know why you should bother with that.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload