This is the mail archive of the mauve-discuss@sources.redhat.com mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] locale and date formatting dependent test ingnu/testlet/java/util/SimpleTimeZone/check12.java


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
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  <noa@resare.com>
+
+	* gnu/testlet/java/util/SimpleTimeZone/check12.java:
+	moved from localedependant DateFormat to SimpleDateFormat
+
 2004-10-07  Noa Resare  <noa@resare.com>
 
 	* 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));
   }
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]