summaryrefslogtreecommitdiffstats
path: root/luni/src/main/java/java/util/Date.java
diff options
context:
space:
mode:
Diffstat (limited to 'luni/src/main/java/java/util/Date.java')
-rw-r--r--luni/src/main/java/java/util/Date.java28
1 files changed, 16 insertions, 12 deletions
diff --git a/luni/src/main/java/java/util/Date.java b/luni/src/main/java/java/util/Date.java
index 0eab8dc..0e1154c 100644
--- a/luni/src/main/java/java/util/Date.java
+++ b/luni/src/main/java/java/util/Date.java
@@ -356,6 +356,10 @@ public class Date implements Serializable, Cloneable, Comparable<Date> {
return -1;
}
+ private static IllegalArgumentException parseError(String string) {
+ throw new IllegalArgumentException("Parse error: " + string);
+ }
+
/**
* Returns the millisecond value of the date and time parsed from the
* specified {@code String}. Many date/time formats are recognized, including IETF
@@ -406,7 +410,7 @@ public class Date implements Serializable, Cloneable, Comparable<Date> {
} else if ('0' <= next && next <= '9') {
nextState = NUMBERS;
} else if (!Character.isSpace(next) && ",+-:/".indexOf(next) == -1) {
- throw new IllegalArgumentException();
+ throw parseError(string);
}
if (state == NUMBERS && nextState != NUMBERS) {
@@ -426,7 +430,7 @@ public class Date implements Serializable, Cloneable, Comparable<Date> {
zoneOffset = sign == '-' ? -digit : digit;
sign = 0;
} else {
- throw new IllegalArgumentException();
+ throw parseError(string);
}
} else if (digit >= 70) {
if (year == -1
@@ -434,7 +438,7 @@ public class Date implements Serializable, Cloneable, Comparable<Date> {
|| next == '/' || next == '\r')) {
year = digit;
} else {
- throw new IllegalArgumentException();
+ throw parseError(string);
}
} else if (next == ':') {
if (hour == -1) {
@@ -442,7 +446,7 @@ public class Date implements Serializable, Cloneable, Comparable<Date> {
} else if (minute == -1) {
minute = digit;
} else {
- throw new IllegalArgumentException();
+ throw parseError(string);
}
} else if (next == '/') {
if (month == -1) {
@@ -450,7 +454,7 @@ public class Date implements Serializable, Cloneable, Comparable<Date> {
} else if (date == -1) {
date = digit;
} else {
- throw new IllegalArgumentException();
+ throw parseError(string);
}
} else if (Character.isSpace(next) || next == ','
|| next == '-' || next == '\r') {
@@ -463,30 +467,30 @@ public class Date implements Serializable, Cloneable, Comparable<Date> {
} else if (year == -1) {
year = digit;
} else {
- throw new IllegalArgumentException();
+ throw parseError(string);
}
} else if (year == -1 && month != -1 && date != -1) {
year = digit;
} else {
- throw new IllegalArgumentException();
+ throw parseError(string);
}
} else if (state == LETTERS && nextState != LETTERS) {
String text = buffer.toString().toUpperCase(Locale.US);
buffer.setLength(0);
if (text.length() == 1) {
- throw new IllegalArgumentException();
+ throw parseError(string);
}
if (text.equals("AM")) {
if (hour == 12) {
hour = 0;
} else if (hour < 1 || hour > 12) {
- throw new IllegalArgumentException();
+ throw parseError(string);
}
} else if (text.equals("PM")) {
if (hour == 12) {
hour = 0;
} else if (hour < 1 || hour > 12) {
- throw new IllegalArgumentException();
+ throw parseError(string);
}
hour += 12;
} else {
@@ -503,7 +507,7 @@ public class Date implements Serializable, Cloneable, Comparable<Date> {
zone = true;
zoneOffset = value;
} else {
- throw new IllegalArgumentException();
+ throw parseError(string);
}
}
}
@@ -549,7 +553,7 @@ public class Date implements Serializable, Cloneable, Comparable<Date> {
return new Date(year - 1900, month, date, hour, minute, second)
.getTime();
}
- throw new IllegalArgumentException();
+ throw parseError(string);
}
/**