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
This commit is contained in:
Sven de Marothy 2005-03-23 22:26:00 +01:00 committed by Tom Tromey
parent 85c4f26a86
commit 8d3ece5d90
4 changed files with 54 additions and 22 deletions

View file

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