Date: Mon, 29 Sep 2003 18:51:18 -0700 From: Jeff Nai <jnai@juniper.net> To: freebsd-java@freebsd.org Cc: Jeff Nai <jnai@juniper.net> Subject: java 1.4 not setting time zone correctly ... Message-ID: <3F78E196.7050006@juniper.net>
next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------080007040108040705020700 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit On FreeBSD, java 1.4 always defaults time zone to GMT. I'd like to know if this is a known bug. % uname -smr FreeBSD 4.8-RELEASE i386 java -version java version "1.4.1-p3" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-p3-jnai_15_sep_2003_19_22) Java HotSpot(TM) Client VM (build 1.4.1-p3-jnai_15_sep_2003_19_22, mixed mode) % java TimeTest old: GMT new: US/Pacific shell: Mon Sep 29 18:41:24 PDT 2003 normal: Tue Sep 30 01:41:24 GMT 2003 adjusted: Mon Sep 29 18:41:24 GMT 2003 On linxu, time zone is set correctly: % uname -smr Linux 2.4.7-10 i686 % java -version java version "1.4.2" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28) Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode) % java TimeTest old: US/Pacific new: US/Pacific shell: Mon Sep 29 18:48:47 PDT 2003 normal: Mon Sep 29 18:48:47 PDT 2003 adjusted: Mon Sep 29 11:48:47 PDT 2003 Thanks, Jeff Nai --------------080007040108040705020700 Content-Type: text/plain; name="TimeTest.java" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="TimeTest.java" import java.io.InputStream; import java.io.IOException; import java.sql.Timestamp; import java.util.Date; import java.util.Properties; import java.text.SimpleDateFormat; public class TimeTest { public static void main(String[] args) { final SimpleDateFormat DATE = new SimpleDateFormat("EEE MMM dd kk:mm:ss zzz yyyy"); // change time zone setting System.out.println("old: " + System.setProperty("user.timezone", "US/Pacific")); System.out.println("new: " + System.getProperty("user.timezone")); // output from 'date' System.out.print("shell: "); try { Process child = Runtime.getRuntime().exec("date"); InputStream in = child.getInputStream(); int c; while ((c = in.read()) != -1) { System.out.print((char)c); } } catch (IOException e) {} // output from vm System.out.println("normal: " + DATE.format(new Date())); // dirty hack! Timestamp ts = new Timestamp(System.currentTimeMillis() - 25200000); System.out.println("adjusted: " + DATE.format(ts)); } } --------------080007040108040705020700--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3F78E196.7050006>