Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 142927 - Java 1.5.0_07 does not know the timezone
Summary: Java 1.5.0_07 does not know the timezone
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal
Assignee: Java team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-05 15:35 UTC by Kevin O'Gorman
Modified: 2006-09-08 07:05 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin O'Gorman 2006-08-05 15:35:54 UTC
Using a Java I emerged just today (though this is probably not a new problem),
I find I get bad results from the DateFormat class.  The minutes are right,
but I'm in Pacific time, and it's off by 7 hours (my 3PM is printed as 10PM).

I found that in the results of java.util.Properties.getProperties().list(System.out)
I see the line
user.timezone=
with no value.  I suspect this is the problem, but it should just track the
local timezone.  My /etc/timezone reads "America/Los_Angeles", and the output
of the date(1) command looks like:
Sat Aug  5 15:33:11 PDT 2006
right when it should.


Gentoo Base System version 1.6.15
Portage 2.1-r1 (default-linux/x86/2005.1, gcc-3.4.6, glibc-2.3.6-r4, 2.6.16-gentoo-r13-kosmanor i686)
=================================================================
System uname: 2.6.16-gentoo-r13-kosmanor i686 Intel(R) XEON(TM) CPU 1.80GHz
ccache version 2.3 [disabled]
app-admin/eselect-compiler: [Not Present]
dev-lang/python:     2.4.3-r1
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     2.3
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.59-r7
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.13-r3
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=pentium4 -fomit-frame-pointer -pipe -mfpmath=sse -msse2 -mmmx"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/lib/X11/xkb /usr/lib/mozilla/defaults/pref /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/bind"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/java-config/vms/ /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-O2 -march=pentium4 -fomit-frame-pointer -pipe -mfpmath=sse -msse2 -mmmx"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig buildpkg distlocks metadata-transfer sandbox sfperms strict"
GENTOO_MIRRORS="ftp://fido.online.kz/gentoo/pub http://gentoo.inf.elte.hu/ ftp://ftp.isu.edu.tw/pub/Linux/Gentoo http://gentoo.scphost.com"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage"
USE="x86 X Xaw3d acl acpi aim alsa apache2 apm arts avi bash-completion bcmath berkdb bitmap-fonts calendar caps cdr cli crypt cscope ctype cups dbm dlloader doc dri dvd dvdr eds emboss encode ethereal exif fastcgi foomaticdb fortran gdbm gif gnome gphoto2 gpm gstreamer gtk gtk2 guile icq imagemagik imap imlib ipv6 isdnlog java joystick jpeg junit kde kerberos libg++ libwww mad mbox mcal mikmod mime mmap mmx motif mp3 mpeg mpi msession mysql ncurses nis nls nsplugin odbc offensive ogg oggvorbis openal opengl oscar oss pam pcre pdflib perl pic png posix postgres ppds pppd python qt qt3 qt4 quicktime readline reflection ruby samba sdl session snmp sockets spell spl sse ssl svga sysvipc tcltk tcpd tetex tiff truetype truetype-fonts type1-fonts usb vorbis xml2 xmms xorg xpm xv yahoo zlib elibc_glibc input_devices_keyboard input_devices_mouse input_devices_joystick kernel_linux userland_GNU video_cards_ati video_cards_vga video_cards_vesa video_cards_fbdev"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Petteri Räty (RETIRED) gentoo-dev 2006-09-03 05:25:54 UTC
Sorry that no-one has replied to this so far. It seems I also have user.timezone empty on my system. Could you provide an example source for me to test with. I am quite busy with other more important stuff atm and that would help with testing this. Most likely this is a problem with the upstream Sun implementation and needs to be reported to bugs.sun.com, but let's not rule out a Gentoo problem just yet.
Comment 2 Petteri Räty (RETIRED) gentoo-dev 2006-09-03 05:35:05 UTC
http://www.javaworld.com/javaworld/jw-10-2003/jw-1003-time-p3.html

Looking there, user.timezone is probably something that the user can set if he/she wants.
Comment 3 Petteri Räty (RETIRED) gentoo-dev 2006-09-03 05:40:47 UTC
At least the following code works fine here:
		java.util.Date date = new java.util.Date();
		System.out.println(date);
Sun Sep 03 15:38:56 EEST 2006
betelgeuse@pena ~/test/java $ date
Sun Sep  3 15:40:00 EEST 2006
Comment 4 Kevin O'Gorman 2006-09-03 21:07:03 UTC
(In reply to comment #2)
> http://www.javaworld.com/javaworld/jw-10-2003/jw-1003-time-p3.html
> 
> Looking there, user.timezone is probably something that the user can set if
> he/she wants.
> 

I could do it.  I'm not satisfied that I can tell 90 students per term to do it and expect them to get it right.  I need a way that works once and for all.
Comment 5 Kevin O'Gorman 2006-09-03 21:31:27 UTC
(In reply to comment #3)
> At least the following code works fine here:
>                 java.util.Date date = new java.util.Date();
>                 System.out.println(date);
> Sun Sep 03 15:38:56 EEST 2006
> betelgeuse@pena ~/test/java $ date
> Sun Sep  3 15:40:00 EEST 2006
> 

How completely unexpected! But this is hardly helpful, because it turns
out that Date and Calendar know some stuff that is not being communicated
to DateFormat.  Here's a bit more code:
import java.util.Calendar;
import java.text.DateFormat;

public class Time {
    public static void main(String [] args) {
        Calendar cal = Calendar.getInstance();
        DateFormat dfmt = DateFormat.getDateTimeInstance();
        System.out.println(new java.util.Date());
        System.out.println(dfmt.format(new java.util.Date()));
        System.out.println("Zone Offset: "
                + (cal.get(java.util.Calendar.ZONE_OFFSET)/(60*60*1000)));
        System.out.println("DST Offset: "
                + (cal.get(java.util.Calendar.DST_OFFSET)/(60*60*1000)));
        dfmt.setCalendar(cal);
        System.out.println(dfmt.format(new java.util.Date()));

    }
}

On my system it outputs:
Sun Sep 03 21:25:46 PDT 2006
Sep 3, 2006 9:25:46 PM
Zone Offset: -8
DST Offset: 1
Sep 3, 2006 9:25:46 PM

Note that the offsets are correct for me, as I'm in the
America/Los Angeles
time zone.

But that last line means that even though the Calendar object knows the
timezone, and I set that Timezone into the DateFormat, it
still acts as if I live in Greenwich.

Can somebody get these pieces to talk to each other?
Comment 6 Kevin O'Gorman 2006-09-03 21:58:18 UTC
Oops.  I was tired when I wrote that and didn't notice that I'm getting the
right results now.  It was indeed 9 PM, and that's the same as 21:00.

I don't know what changed, because I still have user.timezone empty.
But now, all time objects are doing the right thing.  I'm just left
wondering why I still have an empty timezone.  But my students will never
notice and this suddenly got a lot less vital.

I'm currently on java 1.5.0_08, if that matters.  I reported the bug
on the previous version 1.5.0_07

I'm setting this "FIXED".
Comment 7 Petteri Räty (RETIRED) gentoo-dev 2006-09-08 07:05:36 UTC
(In reply to comment #6)
> 
> I'm currently on java 1.5.0_08, if that matters.  I reported the bug
> on the previous version 1.5.0_07
> 
> I'm setting this "FIXED".
> 

Probably fixed by sun in _08 as the release notes seem to have quite a few time related things.

http://java.sun.com/j2se/1.5.0/ReleaseNotes.html#150_08