* [PATCH] locale and date formatting dependent test in gnu/testlet/java/util/SimpleTimeZone/check12.java
@ 2004-10-08 21:42 Noa Resare
0 siblings, 0 replies; only message in thread
From: Noa Resare @ 2004-10-08 21:42 UTC (permalink / raw)
To: Mauve Discuss
[-- Attachment #1: Type: text/plain, Size: 1257 bytes --]
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
[-- Attachment #2: 03-mauve-SimpleTimeZone.patch --]
[-- Type: text/x-patch, Size: 1392 bytes --]
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));
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-10-08 21:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-08 21:42 [PATCH] locale and date formatting dependent test in gnu/testlet/java/util/SimpleTimeZone/check12.java Noa Resare
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).