diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-23 21:26:00 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-23 21:26:00 +0000 |
commit | f28fe27f3113662a38e1387cb483ff960219c422 (patch) | |
tree | fdb34ce03f86ab0625684dbe5615ad44586e2228 /libjava/java/text | |
parent | 22d320f5177efd0eb22fd0f21c8d4d63af54ac9e (diff) | |
download | gcc-f28fe27f3113662a38e1387cb483ff960219c422.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@96951 138bc75d-0d04-0410-961f-82ee72b054a4
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 c1eb3cd3a70..190b4d624f4 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); } |