From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2290 invoked by alias); 8 Oct 2004 21:42:38 -0000 Mailing-List: contact mauve-discuss-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-discuss-owner@sources.redhat.com Received: (qmail 2278 invoked from network); 8 Oct 2004 21:42:37 -0000 Received: from unknown (HELO johanna.resare.com) (193.14.119.138) by sourceware.org with SMTP; 8 Oct 2004 21:42:37 -0000 Received: from molly.resare.com (c-2f1f72d5.01-60-6c6b701.cust.bredbandsbolaget.se [213.114.31.47]) by johanna.resare.com (Postfix) with ESMTP id A64B6D6D09 for ; Fri, 8 Oct 2004 23:42:31 +0200 (CEST) Received: from [192.168.110.42] (marit [192.168.110.42]) by molly.resare.com (Postfix) with ESMTP id 6FA1ED2D10 for ; Fri, 8 Oct 2004 23:42:36 +0200 (CEST) Subject: [PATCH] locale and date formatting dependent test in gnu/testlet/java/util/SimpleTimeZone/check12.java From: Noa Resare To: Mauve Discuss Content-Type: multipart/mixed; boundary="=-nTDLyeQ13iskqwCzYZDN" Date: Fri, 08 Oct 2004 21:42:00 -0000 Message-Id: <1097271756.29859.12.camel@localhost.localdomain> Mime-Version: 1.0 X-SW-Source: 2004-q4/txt/msg00006.txt.bz2 --=-nTDLyeQ13iskqwCzYZDN Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1257 While poking around in gnu/testlet/java/util/SimpleTimeZone/check12.java i found the following code: Date date = new Date(1034705556525l); TimeZone zone = TimeZone.getTimeZone("EST"); DateFormat dateFormat = DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.LONG, Locale.getDefault()); dateFormat.setTimeZone(zone); harness.check("10/15/2002 2:12:36 PM EDT", dateFormat.format(date)); To me this seems problematic for two reasons: 1) The test depends on the locale of the test environment 2) More generally it depends on exactly matching formatting rules from the DateFormat instance, something I believe is not specified. In other words it is possible that a spec conforming implementation fails the test because it formats dates in a slightly different way. In the attached patch i have replaced the getDateTimeInstance() call with a SimpleDateFormat that should behave consistently in all locales and jvms. Please apply. Since I have a few patches now awaiting review/comments/inclusion/rejection I have collected them in http://resare.com/noa/mauve/patches for easy access. If anyone wants to try them out, apply them in lexical order. /noa --=-nTDLyeQ13iskqwCzYZDN Content-Disposition: attachment; filename=03-mauve-SimpleTimeZone.patch Content-Type: text/x-patch; name=03-mauve-SimpleTimeZone.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 1392 diff -ur mauve.clean/ChangeLog mauve.work/ChangeLog --- mauve.clean/ChangeLog 2004-10-08 23:21:23.226938531 +0200 +++ mauve.work/ChangeLog 2004-10-08 23:27:54.473432497 +0200 @@ -1,3 +1,8 @@ +2004-10-08 Noa Resare + + * gnu/testlet/java/util/SimpleTimeZone/check12.java: + moved from localedependant DateFormat to SimpleDateFormat + 2004-10-07 Noa Resare * gnu/testlet/java/net/DatagramPacket/DatagramPacketTest2.java diff -ur mauve.clean/gnu/testlet/java/util/SimpleTimeZone/check12.java mauve.work/gnu/testlet/java/util/SimpleTimeZone/check12.java --- mauve.clean/gnu/testlet/java/util/SimpleTimeZone/check12.java 2004-10-08 23:08:29.553739970 +0200 +++ mauve.work/gnu/testlet/java/util/SimpleTimeZone/check12.java 2004-10-08 23:26:02.254778854 +0200 @@ -138,11 +138,8 @@ // PR libgcj/8321 Date date = new Date(1034705556525l); TimeZone zone = TimeZone.getTimeZone("EST"); - DateFormat dateFormat = DateFormat.getDateTimeInstance( - DateFormat.SHORT, - DateFormat.LONG, - Locale.getDefault()); + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); dateFormat.setTimeZone(zone); - harness.check("10/15/2002 2:12:36 PM EDT", dateFormat.format(date)); + harness.check("2002-10-15 14:12:36 EDT", dateFormat.format(date)); } } --=-nTDLyeQ13iskqwCzYZDN--