summaryrefslogtreecommitdiffstats
path: root/libjava/java/util/GregorianCalendar.java
diff options
context:
space:
mode:
authorbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>2004-10-10 16:19:37 +0000
committerbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>2004-10-10 16:19:37 +0000
commitade458e36af8e831f53a6a52e432f588e72fb028 (patch)
tree24be0ef56d3c74ad47155697e7641564c0c6fad0 /libjava/java/util/GregorianCalendar.java
parentf912725f97e9f5116173ac4c46d0c1e39f2cdd67 (diff)
downloadppe42-gcc-ade458e36af8e831f53a6a52e432f588e72fb028.tar.gz
ppe42-gcc-ade458e36af8e831f53a6a52e432f588e72fb028.zip
2004-10-08 Bryce McKinlay <mckinlay@redhat.com>
* java/util/Calendar.java (set): Invalidate DST_OFFSET field as a DST boundary may have been crossed. * java/util/GregorianCalendar.java (add): Throw IllegalArgumentException on attempt to add to DST_OFFSET or ZONE_OFFSET fields. Update javadoc. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@88847 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/util/GregorianCalendar.java')
-rw-r--r--libjava/java/util/GregorianCalendar.java17
1 files changed, 6 insertions, 11 deletions
diff --git a/libjava/java/util/GregorianCalendar.java b/libjava/java/util/GregorianCalendar.java
index fcef6bb4560..2504f603427 100644
--- a/libjava/java/util/GregorianCalendar.java
+++ b/libjava/java/util/GregorianCalendar.java
@@ -540,7 +540,7 @@ public class GregorianCalendar extends Calendar
fields[DAY_OF_WEEK] = weekday;
// get a first approximation of the year. This may be one
- // year to big.
+ // year too big.
int year = 1970 + (gregorian
? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1)
: ((day - 100) * 4) / (365 * 4 + 1));
@@ -709,6 +709,10 @@ public class GregorianCalendar extends Calendar
* it does what you expect: Jan, 25 + 10 Days is Feb, 4.
* @param field the time field. One of the time field constants.
* @param amount the amount of time.
+ * @exception IllegalArgumentException if <code>field</code> is
+ * <code>ZONE_OFFSET</code>, <code>DST_OFFSET</code>, or invalid; or
+ * if <code>amount</code> contains an out-of-range value and the calendar
+ * is not in lenient mode.
*/
public void add(int field, int amount)
{
@@ -785,18 +789,9 @@ public class GregorianCalendar extends Calendar
areFieldsSet = false;
break;
case ZONE_OFFSET:
- complete();
- fields[ZONE_OFFSET] += amount;
- time -= amount;
- break;
case DST_OFFSET:
- complete();
- fields[DST_OFFSET] += amount;
- isTimeSet = false;
- break;
default:
- throw new IllegalArgumentException
- ("Unknown Calendar field: " + field);
+ throw new IllegalArgumentException("Invalid or unknown field");
}
}
OpenPOWER on IntegriCloud