Overlapping timezones

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Overlapping timezones

Johannes Ulfkjær Jensen
Hi,

This question concerns the issue of "overlapping timezones" like Europe/Copenhagen.

I am parsing a sequence of timestamps in Europe/Copenhagen like:

2009-10-25 01:00
2009-10-25 02:00
2009-10-25 02:00
2009-10-25 03:00
2009-10-25 04:00

with a DateTimeFormatter created this way:

DateTimeFormat.forPattern("YYYY-MM-dd HH:mm").withZone(DateTimeZone.forID("Europe/Copenhagen"));

The goal is to reconstruct the time in UTC.

When DST ends, the clock is set one hour back and we have to identical strings of that point in time. Currently I detect this with a bunch of getZone().getOffset() and some plus/minusHours() calls and but it seems I still need to know which of the offsets the DateTimeFormatter.parseDateTime is going to choose on this overlap. Is this defined anywhere?

Also, this seems quite messy. Is there any better way of going at it ?

Kind regards
Johannes
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Overlapping timezones

jodastephen
On 2 February 2012 13:15, Johannes Ulfkjær Jensen <[hidden email]> wrote:
> I am parsing a sequence of timestamps in Europe/Copenhagen like:
>
> 2009-10-25 01:00
> 2009-10-25 02:00
> 2009-10-25 02:00
> 2009-10-25 03:00
> 2009-10-25 04:00

These are not timestamps ;-) They are local representations of date
and time. There is insufficient information in those strings to
accurateyl parse the correct point in UTC. Whereas there is enough
information here (and parser support for it)

2009-10-25 01:00+02:00
2009-10-25 02:00+02:00
2009-10-25 02:00+01:00
2009-10-25 03:00+01:00

> When DST ends, the clock is set one hour back and we have to identical strings of that point in time. Currently I detect this with a bunch of getZone().getOffset() and some plus/minusHours() calls and but it seems I still need to know which of the offsets the DateTimeFormatter.parseDateTime is going to choose on this overlap. Is this defined anywhere?

The methods withEarlierOffset() and withLaterOffset() allow you to
create the DateTime object and then adjust it if necessary afterwards.
(Fix made in git today to the withLaterOffset() method.

> Also, this seems quite messy. Is there any better way of going at it ?

If you are inventing information out of thin air, then the code is
necessarilty going to be messy!

Stephen

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Loading...