diff options
author | Sven de Marothy <sven@physto.se> | 2005-03-23 22:26:00 +0100 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2005-03-23 21:26:00 +0000 |
commit | 8d3ece5d900e311a6b1548885a2535bd93fa86df (patch) | |
tree | fdb34ce03f86ab0625684dbe5615ad44586e2228 /libjava/java/text | |
parent | 85c4f26a8651192648d1d4ce37009d838abe4152 (diff) | |
download | gcc-8d3ece5d900e311a6b1548885a2535bd93fa86df.zip gcc-8d3ece5d900e311a6b1548885a2535bd93fa86df.tar.gz gcc-8d3ece5d900e311a6b1548885a2535bd93fa86df.tar.bz2 |
PR libgcj/2641, PR libgcj/9854, PR libgcj/14892, PR libgcj/18083,
2005-03-23 Sven de Marothy <sven@physto.se>
PR libgcj/2641, PR libgcj/9854, PR libgcj/14892, PR libgcj/18083,
PR libgcj/11085:
* java/util/Calendar.java
(set): Use starting day of week when one is needed if none is given.
* java/text/SimpleDateFormat.java
(parse): Handle 1-12 and 1-24 timestamps correctly.
* java/util/GregorianCalendar.java
(computeTime, computeFields): HOUR should be in 0-11 format.
(nonLeniencyCheck): Adjust leniency checking to that fact.
(getLinearDay): Should be private.
From-SVN: r96951
Diffstat (limited to 'libjava/java/text')
-rw-r--r-- | libjava/java/text/SimpleDateFormat.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libjava/java/text/SimpleDateFormat.java b/libjava/java/text/SimpleDateFormat.java index c1eb3cd..190b4d6 100644 --- a/libjava/java/text/SimpleDateFormat.java +++ b/libjava/java/text/SimpleDateFormat.java @@ -916,6 +916,8 @@ public class SimpleDateFormat extends DateFormat boolean is_numeric = true; int offset = 0; boolean maybe2DigitYear = false; + boolean oneBasedHour = false; + boolean oneBasedHourOfDay = false; Integer simpleOffset; String[] set1 = null; String[] set2 = null; @@ -964,12 +966,14 @@ public class SimpleDateFormat extends DateFormat break; case 'h': calendar_field = Calendar.HOUR; + oneBasedHour = true; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; + oneBasedHourOfDay = true; break; case 'm': calendar_field = Calendar.MINUTE; @@ -1108,6 +1112,14 @@ public class SimpleDateFormat extends DateFormat } } + // Calendar uses 0-based hours. + // I.e. 00:00 AM is midnight, not 12 AM or 24:00 + if (oneBasedHour && value == 12) + value = 0; + + if (oneBasedHourOfDay && value == 24) + value = 0; + // Assign the value and move on. calendar.set(calendar_field, value); } |