summaryrefslogtreecommitdiffstats
path: root/luni/src/main/java/java/text/DateFormat.java
diff options
context:
space:
mode:
Diffstat (limited to 'luni/src/main/java/java/text/DateFormat.java')
-rw-r--r--luni/src/main/java/java/text/DateFormat.java21
1 files changed, 8 insertions, 13 deletions
diff --git a/luni/src/main/java/java/text/DateFormat.java b/luni/src/main/java/java/text/DateFormat.java
index b45e699..5ad4bb5 100644
--- a/luni/src/main/java/java/text/DateFormat.java
+++ b/luni/src/main/java/java/text/DateFormat.java
@@ -349,16 +349,14 @@ public abstract class DateFormat extends Format {
* {@code Number} instance.
*/
@Override
- public final StringBuffer format(Object object, StringBuffer buffer,
- FieldPosition field) {
+ public final StringBuffer format(Object object, StringBuffer buffer, FieldPosition field) {
if (object instanceof Date) {
return format((Date) object, buffer, field);
}
if (object instanceof Number) {
- return format(new Date(((Number) object).longValue()), buffer,
- field);
+ return format(new Date(((Number) object).longValue()), buffer, field);
}
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Bad class: " + object.getClass());
}
/**
@@ -369,8 +367,7 @@ public abstract class DateFormat extends Format {
* @return the formatted string.
*/
public final String format(Date date) {
- return format(date, new StringBuffer(), new FieldPosition(0))
- .toString();
+ return format(date, new StringBuffer(), new FieldPosition(0)).toString();
}
/**
@@ -391,8 +388,7 @@ public abstract class DateFormat extends Format {
* of the alignment field in the formatted text.
* @return the string buffer.
*/
- public abstract StringBuffer format(Date date, StringBuffer buffer,
- FieldPosition field);
+ public abstract StringBuffer format(Date date, StringBuffer buffer, FieldPosition field);
/**
* Returns an array of locales for which custom {@code DateFormat} instances
@@ -874,9 +870,8 @@ public abstract class DateFormat extends Format {
*/
public static Field ofCalendarField(int calendarField) {
if (calendarField < 0 || calendarField >= Calendar.FIELD_COUNT) {
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Field out of range: " + calendarField);
}
-
return table.get(Integer.valueOf(calendarField));
}
}
@@ -884,14 +879,14 @@ public abstract class DateFormat extends Format {
private static void checkDateStyle(int style) {
if (!(style == SHORT || style == MEDIUM || style == LONG
|| style == FULL || style == DEFAULT)) {
- throw new IllegalArgumentException("Illegal date style " + style);
+ throw new IllegalArgumentException("Illegal date style: " + style);
}
}
private static void checkTimeStyle(int style) {
if (!(style == SHORT || style == MEDIUM || style == LONG
|| style == FULL || style == DEFAULT)) {
- throw new IllegalArgumentException("Illegal time style " + style);
+ throw new IllegalArgumentException("Illegal time style: " + style);
}
}
}