From owner-freebsd-java@FreeBSD.ORG Mon Sep 29 18:51:19 2003 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4CA6116A4BF for ; Mon, 29 Sep 2003 18:51:19 -0700 (PDT) Received: from merlot.juniper.net (natint2.juniper.net [207.17.136.150]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7F8FC4400F for ; Mon, 29 Sep 2003 18:51:18 -0700 (PDT) (envelope-from jnai@juniper.net) Received: from juniper.net (tass.juniper.net [172.17.12.39]) by merlot.juniper.net (8.11.3/8.11.3) with ESMTP id h8U1pIj48296; Mon, 29 Sep 2003 18:51:18 -0700 (PDT) (envelope-from jnai@juniper.net) Message-ID: <3F78E196.7050006@juniper.net> Date: Mon, 29 Sep 2003 18:51:18 -0700 From: Jeff Nai User-Agent: Mozilla/5.0 (X11; U; Linux i386; en-US; rv:0.9.4) Gecko/20011126 Netscape6/6.2.1 X-Accept-Language: en-us MIME-Version: 1.0 To: freebsd-java@freebsd.org Content-Type: multipart/mixed; boundary="------------080007040108040705020700" cc: Jeff Nai Subject: java 1.4 not setting time zone correctly ... X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Sep 2003 01:51:19 -0000 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--