--- a/jdk/src/share/classes/java/time/temporal/ValueRange.java Thu Apr 11 19:15:24 2013 -0700
+++ b/jdk/src/share/classes/java/time/temporal/ValueRange.java Fri Apr 12 07:57:35 2013 -0700
@@ -305,11 +305,7 @@
*/
public long checkValidValue(long value, TemporalField field) {
if (isValidValue(value) == false) {
- if (field != null) {
- throw new DateTimeException("Invalid value for " + field.getName() + " (valid values " + this + "): " + value);
- } else {
- throw new DateTimeException("Invalid value (valid values " + this + "): " + value);
- }
+ throw new DateTimeException(genInvalidFieldMessage(field, value));
}
return value;
}
@@ -328,11 +324,19 @@
*/
public int checkValidIntValue(long value, TemporalField field) {
if (isValidIntValue(value) == false) {
- throw new DateTimeException("Invalid int value for " + field.getName() + ": " + value);
+ throw new DateTimeException(genInvalidFieldMessage(field, value));
}
return (int) value;
}
+ private String genInvalidFieldMessage(TemporalField field, long value) {
+ if (field != null) {
+ return "Invalid value for " + field.getName() + " (valid values " + this + "): " + value;
+ } else {
+ return "Invalid value (valid values " + this + "): " + value;
+ }
+ }
+
//-----------------------------------------------------------------------
/**
* Checks if this range is equal to another range.