[
https://issues.apache.org/jira/browse/SLING-4347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14729188#comment-14729188
]
Konrad Windszus commented on SLING-4347:
----------------------------------------
We should first of all further clarify the fact, that only dates given in
ISO8601 format keep the timezone and all others loose it in
https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#date-properties.
This is due to the fact that the {{Date}} object does not store this offset
(see also
https://groups.google.com/forum/#!topic/comp.lang.java.programmer/uAdwiz8-Dgo)
and all other formats except ISO8601 use the Date object only to initialize the
Calendar.
Changing this is not that simple though, because only Java 8 introduced some
more sophisticated time/date classes
(http://www.oracle.com/technetwork/articles/java/jf14-date-time-2125367.html).
Although {{Calendar}} objects support storing the timezone offset, that
timezone needs to be set explicitly. If you rely on the parsing of some of the
pre-Java8 classes you cannot really get that to work. So the option would be to
extract that manually from the date (after the Java Date object was given), but
I would guess this is just too much effort.
I would rather suggest to close this as Won't Fix and clearly document that the
timezone is lost, whenever you store it through the Sling POST Servlet if you
don't give it in ISO8601 format.
> When a timezone is provided in a Date, it should be stored as provided
> ----------------------------------------------------------------------
>
> Key: SLING-4347
> URL: https://issues.apache.org/jira/browse/SLING-4347
> Project: Sling
> Issue Type: Bug
> Components: Servlets
> Reporter: Santiago GarcĂa Pimentel
>
> Whenever a POST request is made and it contains a date string with a timezone
> in it. Sling turns it into the JVM local time and looses the provided
> timezone. The only exception for this is when the date is provided in the
> ISO8601 format, which uses a different date formatter.
> Sling should instead preserve the date as it is provided.
> This happens because Sling uses a SimpleDateFormat object to parse the Date
> string, which returns a date object.
> We could follow an approach like org.apache.jackrabbit.util.ISO8601 to
> achieve this.
> http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/ISO8601.java
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)