Results 1 to 3 of 3

Thread: Java giving wrong time

  1. #1
    Join Date
    Aug 2006
    Location
    60°27'48"N 24°48'18"E
    Beans
    3,458

    Unhappy [SOLVED] Java giving wrong time

    Ok, this is on Debian Etch so not really Ubuntu but I think I'll ask anyway as it's likely someone is able to give me a good answer...

    I am setting up a Java web application on my new Debian server, and running into an oddity with Java's time. System time and timezone are correct as far as I know:

    Code:
    Your default time zone is set to 'Europe/Helsinki'.
    Local time is now:      Sun Sep 16 07:25:02 EEST 2007.
    Universal Time is now:  Sun Sep 16 04:25:02 UTC 2007.
    However, with Java code that essentially does System.out.println(new Date()) we get:

    Code:
    voitto:~# java Testi
    Sun Sep 16 06:30:45 GMT+02:00 2007
    So Java is an hour behind -- This is going to be a total showstopper for this deployment until it is resolved

    Nothing like this on my Ubuntu development box! It probably has something to do with summer time, but no idea how to fix this...
    Last edited by CptPicard; September 16th, 2007 at 06:19 AM.

  2. #2
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,285
    Distro
    Kubuntu

    Re: Java giving wrong time

    Maybe this article will help you.

  3. #3
    Join Date
    Aug 2006
    Location
    60°27'48"N 24°48'18"E
    Beans
    3,458

    Re: Java giving wrong time

    Thanks lots for the pointer, looks like the problem I'm having... reading it now.

    Quite unforgivable of Java really to have such a fundamental behaviour difference even between two Linuxes, both running Java 1.5.. "Write once run anywhere", my ***

    EDIT: Ok, so it's a matter of setting TZ or -Duser.timezone=Europe/Helsinki. *Phew*. Interesting though that Debian's Sun Java can deduce the GMT+2 bit of timezone information but not the DST adjusted one, while Ubuntu doesn't have TZ set and the Java timezone information is correct....

    EDIT2: Heh, weirdness. Just for posterity, let it be recorded that this solved it. Java doesn't like /etc/localtime unless it's a symlink (which it isn't even on my Ubuntu box), and making it a symlink makes Java like the timezone data
    Last edited by CptPicard; September 16th, 2007 at 06:29 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •