I'm not sure I follow your reasoning. ISO-8601 pretty clearly describes how
time zone offsets will accurately reflect a time zone (see the Wikipedia page
for this for an explanation if you need it).
But in any case, I think your avoiding the issue: joda bases itself on iso8601,
and time zone identifier/offsets are a key part of that spec (in my view, at
least).
From: Brian S O'Neill [mailto:bro...@gmail.com]
Sent: Wednesday, March 31, 2010 10:52 AM
To: joda-interest@lists.sourceforge.net
Subject: Re: [Joda-interest] parsing of UTC dates
Consistency and simplicity. The time zone offset in the date format never
correctly describes a time zone, except in the one special case: 'Z'. If this
case was handled specially, then it might also be described as "unexpected".
Constructing a DateTime by String is limited anyhow, and you'll have much more
precise control by using a DateTimeFormatter of your choice. With it, you can
call withOffsetParsed to preserve the time zone offset.
On 2010-03-31 06:56 AM, Bridges, Ed (Citco) wrote:
It's my understanding from ISO8601 that when you include a trailing 'Z' in a
string form of a date/time that that indicates the timezone as UTC.
However when giving a string of this form to Joda, it instead converts it to
local timezone unless you force it to UTC:
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
public class JodaDateTimeZone {
// example date from ISO spec:
// http://dotat.at/tmp/ISO_8601-2004_E.pdf
private static final String UTC_DATE = "1985-04-12T10:15:30Z";
public static void main(String[] args) {
DateTime dateTime = new DateTime(UTC_DATE);
System.out.println(dateTime.toString());
dateTime = new DateTime(UTC_DATE, DateTimeZone.UTC);
System.out.println(dateTime.toString());
}
}
Can someone explain the rationale behind this unexpected behavior?
Thanks,
Ed
Disclaimer link. To see it, click the link below, or copy and paste it into
your browser's address line.
http://www.citco.com/emaildisclaimer.htm
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest