Ah, okay, this is where my understanding of time and time zones fell
apart; I didn't realize that a fixed offset would not equal a named
time zone. Thinking about the larger world, it makes sense; -6 is not
just US Central Time; sorry about that. :)
So if I may, what would be a best-practice for dealing with time
zones, DST, etc. and Joda? Can Joda figure out whether a date/time
falls within DST based on the date & time zone? It seems like there's
enough there that it should be possible, but given my earlier
question, I'm not going to assume anything. :)
My previous experience with time zones was a specialized mail program
in C++ where I had to write it all myself and it was a total
nightmare; calculating the date against the beginning of DST and end
of DST and then, (assuming a US-centric audience, which this program
was), based on the TZ, deciding to apply an offset or not. Total
madness...I was debugging it for a week.
I guess I have a knee-jerk reaction to time zones and DST in that on
one level, it seems pretty straightforward. But on many other levels,
it's just complete madness (to me, anyway).
On 11/23/08, Brian S O'Neill <[EMAIL PROTECTED]> wrote:
> Calling forOffsetHours returns a time zone with a fixed offset, as per
> the documentation. A fixed offset of 6 hours is not equivalent to CST,
> which has DST rules and other historical transitions. There isn't any
> API in Joda-Time which returns time zones which match a given offset
> because it would return many of them.
>
>
> Ron Olson wrote:
> > Hi all-
> >
> > I assume I'm doing something wrong here, but I've been going through
> > the docs and haven't come up with a reason why this should be
> > happening.
> >
> > Basically, if I create a new DateTime object and pass it a
> > DateTimeZone instance called from forOffsetHours(), when I try to
> > print the time using the DateTimeFormatter, I get -06:00 instead of
> > CST. Below is an example:
> >
> > import org.joda.time.DateTime;
> > import org.joda.time.DateTimeZone;
> >
> > import org.joda.time.format.DateTimeFormat;
> > import org.joda.time.format.DateTimeFormatter;
> >
> > public class TimeTest
> > {
> > public static void main(String[] args)
> > {
> > DateTime dt = new DateTime();
> > DateTimeFormatter calendarTimeFormat =
> DateTimeFormat.forPattern("hh:mm a z");
> > System.out.println(dt.toString() + " - " +
> calendarTimeFormat.print(dt));
> >
> > Integer timeZoneOffset = -6;
> >
> > // And put them together
> > DateTime birthDateTime = new DateTime( 2004,
> > 12,
> >
> 27,
> >
> 16,
> >
> 44,
> >
> 0,
> >
> 0,
> >
> DateTimeZone.forOffsetHours(timeZoneOffset));
> >
> > System.out.println(birthDateTime.toString() + " - " +
> > calendarTimeFormat.print(birthDateTime));
> > }
> >
> > }
> >
> > This will print (as of a couple of minutes ago):
> >
> > 2008-11-22T23:06:27.399-06:00 - 11:06 PM CST
> > 2004-12-27T16:44:30.533-06:00 - 04:44 PM -06:00
> >
> >
> > Might anyone have an idea why this is happening? Any help would be
> appreciated.
> >
> > Ron
> >
>
> > -------------------------------------------------------------------------
> > This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> > Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> > Grand prize is a trip for two to an Open Source event anywhere in the world
> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
> > _______________________________________________
> > Joda-interest mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/joda-interest
> >
> >
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Joda-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Joda-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/joda-interest