public inbox for mauve-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Noa Resare <noa@resare.com>
To: Mauve Discuss <mauve-discuss@sources.redhat.com>
Subject: [PATCH] locale and date formatting dependent test in gnu/testlet/java/util/SimpleTimeZone/check12.java
Date: Fri, 08 Oct 2004 21:42:00 -0000	[thread overview]
Message-ID: <1097271756.29859.12.camel@localhost.localdomain> (raw)

[-- 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));
   }
 }

                 reply	other threads:[~2004-10-08 21:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1097271756.29859.12.camel@localhost.localdomain \
    --to=noa@resare.com \
    --cc=mauve-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).