* FYI: Fix Calendar.ampm test to use localised strings
@ 2008-12-31 10:41 Andrew John Hughes
0 siblings, 0 replies; only message in thread
From: Andrew John Hughes @ 2008-12-31 10:41 UTC (permalink / raw)
To: mauve-patches
[-- Attachment #1: Type: text/plain, Size: 613 bytes --]
This fixes the Calendar.ampm test so it passes on both
GNU Classpath and OpenJDK. The AM/PM strings are localised
and so should be retrieved from the locale data.
ChangeLog:
2008-12-31 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/testlet/java/util/Calendar/ampm.java:
Use the localised am/pm strings from DateFormatSymbols
rather than hardcoding.
--
Andrew :)
Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA 7927 142C 2591 94EF D9D8
[-- Attachment #2: calendar-01.diff --]
[-- Type: text/plain, Size: 2260 bytes --]
Index: gnu/testlet/java/util/Calendar/ampm.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/util/Calendar/ampm.java,v
retrieving revision 1.2
diff -u -u -r1.2 ampm.java
--- gnu/testlet/java/util/Calendar/ampm.java 21 Mar 2005 08:26:05 -0000 1.2
+++ gnu/testlet/java/util/Calendar/ampm.java 31 Dec 2008 10:36:26 -0000
@@ -13,13 +13,14 @@
public class ampm implements Testlet
{
- private DateFormat format;
+ private SimpleDateFormat format;
private TestHarness harness;
public void test (TestHarness harness)
{
// AM/PM mark is locale-dependent. We use Locale.US.
format = new SimpleDateFormat("hh:mm a", Locale.US);
+ String[] ampm = format.getDateFormatSymbols().getAmPmStrings();
this.harness = harness;
// According to the API document of java.util.Calendar,
@@ -31,19 +32,19 @@
// Whereas the 'h' flag is 1-12 time
// I.e. 12 AM (midnight), 1 AM, .. , 12 PM (midday), 1 PM, .. 11 PM
- checkTime("12:00 AM", "12:00 AM");
- checkTime("12:10 AM", "12:10 AM");
- checkTime(0, 0, Calendar.AM, "12:00 AM");
- checkTime("0:00 AM", "12:00 AM");
- checkTime(0, 10, Calendar.AM, "12:10 AM");
- checkTime("0:10 AM", "12:10 AM");
-
- checkTime("12:00 PM", "12:00 PM");
- checkTime("12:10 PM", "12:10 PM");
- checkTime(0, 0, Calendar.PM, "12:00 PM");
- checkTime("0:00 PM", "12:00 PM");
- checkTime(0, 10, Calendar.PM, "12:10 PM");
- checkTime("0:10 PM", "12:10 PM");
+ checkTime("12:00 " + ampm[0], "12:00 " + ampm[0]);
+ checkTime("12:10 " + ampm[0], "12:10 " + ampm[0]);
+ checkTime(0, 0, Calendar.AM, "12:00 " + ampm[0]);
+ checkTime("0:00 " + ampm[0], "12:00 " + ampm[0]);
+ checkTime(0, 10, Calendar.AM, "12:10 " + ampm[0]);
+ checkTime("0:10 " + ampm[0], "12:10 " + ampm[0]);
+
+ checkTime("12:00 " + ampm[1], "12:00 " + ampm[1]);
+ checkTime("12:10 " + ampm[1], "12:10 " + ampm[1]);
+ checkTime(0, 0, Calendar.PM, "12:00 " + ampm[1]);
+ checkTime("0:00 " + ampm[1], "12:00 " + ampm[1]);
+ checkTime(0, 10, Calendar.PM, "12:10 " + ampm[1]);
+ checkTime("0:10 " + ampm[1], "12:10 " + ampm[1]);
}
private void checkTime(int hh, int mm, int ampm, String expect)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-12-31 10:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-31 10:41 FYI: Fix Calendar.ampm test to use localised strings Andrew John Hughes
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).