The java.util.Date object always references the machine's time zone.
Joda-Time cannot change this behaviour, but does ensure that the
correct millis is used.

Stephen


On 21/12/06, Dadi Ingolfsson <[EMAIL PROTECTED]> wrote:
>
>
>
>
> Hi,
>
>
>
> In my unit tests I have been using a helper function that creates a DateTime
> object with a specified DateTimeZone.  I recently relocated to Denmark and
> now some of my unit tests fail because they were expecting GMT (Iceland is
> were I originally come from) in a formatted date string.  The following
> investigating unit test shows my problem:
>
> …
>
> …
>
> public void
> test_ThatCreatingADateTimeWithAFixedZoneBehavesAsExpected()
>
>   {
>
>     DateTime dt = new DateTime(2006, 2, 11, 15, 0, 0, 0,
> DateTimeZone.forID("Atlantic/Reykjavik"));
>
>
>
>     assertEquals("11.02.2006-15:00:00:00-GMT",
> dt.toString("dd.MM.yyyy-HH:mm:ss:SS-z"));
>
>
>
>     assertEquals("Sat Feb 11 15:00:00 GMT 2006", dt.toDate().toString());
>
>
>
>     assertEquals("Sat Feb 11 15:00:00 GMT 2006", new
> Date(dt.getMillis()).toString());
>
>   }
>
> …
>
> …
>
>
>
> The assertEquals statements nr. 2 and 3 both fail because the result turns
> out to be "Sat Feb 11 15:00:00 GMT 2006", which is not what I expected!  Am
> I doing something wrong here or should the conversion from DateTime to Date
> really use the machine´s time zone?
>
>
>
> Best regards,
>
> Dadi.
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
> _______________________________________________
> Joda-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>
>
>

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Joda-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to