summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Benson <gbenson@redhat.com>2007-04-13 15:41:29 +0000
committerGary Benson <gbenson@redhat.com>2007-04-13 15:41:29 +0000
commitd6dbdd71a86bd79ccf888c02defeaa93bd53187d (patch)
tree5c8a0f5dec529c6851d5084aa83190f7880b45c1
parentcfa2da67d8f8895f68d19423d5d379cf72038a93 (diff)
downloadclasspath-gbenson-calendar-branch.tar.gz
2007-04-13 Gary Benson <gbenson@redhat.com>gbenson-calendar-branch
* java/util/GregorianCalendar.java (computeFields): Moved the majority of the logic into... (internalComputeFields): New method. (setDefaultFields): Only set areFieldsSet all fields were set. (computeTime): Sometimes call internalComputeFields.
-rw-r--r--ChangeLog8
-rw-r--r--java/util/GregorianCalendar.java28
2 files changed, 32 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index e6f621912..1b161dc93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,14 @@
2007-04-13 Gary Benson <gbenson@redhat.com>
* java/util/GregorianCalendar.java
+ (computeFields): Moved the majority of the logic into...
+ (internalComputeFields): New method.
+ (setDefaultFields): Only set areFieldsSet all fields were set.
+ (computeTime): Sometimes call internalComputeFields.
+
+2007-04-13 Gary Benson <gbenson@redhat.com>
+
+ * java/util/GregorianCalendar.java
(defaults): Moved from within setDefaultFields.
(setDefaultFields): Only set fields that are undefined.
diff --git a/java/util/GregorianCalendar.java b/java/util/GregorianCalendar.java
index bd5e6897b..fe3a3ff40 100644
--- a/java/util/GregorianCalendar.java
+++ b/java/util/GregorianCalendar.java
@@ -508,10 +508,14 @@ public class GregorianCalendar extends Calendar
*/
private void setDefaultFields()
{
+ boolean areAnyFieldsSet = false;
for (int i = 0; i < FIELD_COUNT; i++)
{
if (isSet[i])
- continue;
+ {
+ areAnyFieldsSet = true;
+ continue;
+ }
if (i == DAY_OF_WEEK)
fields[i] = getFirstDayOfWeek();
@@ -521,7 +525,8 @@ public class GregorianCalendar extends Calendar
// It seems odd that a call to computeTime() should cause
// areFieldsSet to become true, but that's what Sun do...
- areFieldsSet = true;
+ if (!areAnyFieldsSet)
+ areFieldsSet = true;
}
/**
@@ -735,7 +740,10 @@ public class GregorianCalendar extends Calendar
- zone.getRawOffset());
time -= rawOffset + dstOffset;
- }
+
+ if (!areFieldsSet)
+ internalComputeFields();
+}
/**
* Get the linear day in days since the epoch, using the
@@ -848,6 +856,18 @@ public class GregorianCalendar extends Calendar
*/
protected synchronized void computeFields()
{
+ internalComputeFields();
+ for (int i = 0; i < FIELD_COUNT; i++)
+ isSet[i] = true;
+ }
+
+ /**
+ * Converts the milliseconds since the epoch UTC
+ * (<code>time</code>) to time fields
+ * (<code>fields</code>).
+ */
+ private void internalComputeFields()
+ {
boolean gregorian = (time >= gregorianCutover);
TimeZone zone = getTimeZone();
@@ -916,7 +936,7 @@ public class GregorianCalendar extends Calendar
fields[SECOND] = millisInDay / (1000);
fields[MILLISECOND] = millisInDay % 1000;
- areFieldsSet = isSet[ERA] = isSet[YEAR] = isSet[MONTH] = isSet[WEEK_OF_YEAR] = isSet[WEEK_OF_MONTH] = isSet[DAY_OF_MONTH] = isSet[DAY_OF_YEAR] = isSet[DAY_OF_WEEK] = isSet[DAY_OF_WEEK_IN_MONTH] = isSet[AM_PM] = isSet[HOUR] = isSet[HOUR_OF_DAY] = isSet[MINUTE] = isSet[SECOND] = isSet[MILLISECOND] = isSet[ZONE_OFFSET] = isSet[DST_OFFSET] = true;
+ areFieldsSet = true;
}
/**