|
47 | 47 | import org.apache.commons.lang3.ArraySorter; |
48 | 48 | import org.apache.commons.lang3.CharUtils; |
49 | 49 | import org.apache.commons.lang3.LocaleUtils; |
| 50 | +import org.apache.commons.lang3.StringUtils; |
50 | 51 |
|
51 | 52 | /** |
52 | 53 | * FastDateParser is a fast and thread-safe version of {@link java.text.SimpleDateFormat}. |
@@ -323,7 +324,7 @@ boolean parse(final FastDateParser parser, final Calendar calendar, final String |
323 | 324 | */ |
324 | 325 | @Override |
325 | 326 | public String toString() { |
326 | | - return "NumberStrategy [field=" + field + "]"; |
| 327 | + return getClass().getSimpleName() + " [field=" + field + "]"; |
327 | 328 | } |
328 | 329 | } |
329 | 330 |
|
@@ -1027,11 +1028,12 @@ public Date parse(final String source) throws ParseException { |
1027 | 1028 | final Date date = parse(source, pp); |
1028 | 1029 | if (date == null) { |
1029 | 1030 | // Add a note regarding supported date range |
| 1031 | + final int errorIndex = pp.getErrorIndex(); |
| 1032 | + final String msg = String.format("Unparseable date: '%s', parse position = %s", source, pp); |
1030 | 1033 | if (locale.equals(JAPANESE_IMPERIAL)) { |
1031 | | - throw new ParseException("(The " + locale + " locale does not support dates before 1868 AD)\nUnparseable date: \"" + source, |
1032 | | - pp.getErrorIndex()); |
| 1034 | + throw new ParseException(String.format("; the %s locale does not support dates before 1868-01-01.", locale, msg), errorIndex); |
1033 | 1035 | } |
1034 | | - throw new ParseException("Unparseable date: " + source, pp.getErrorIndex()); |
| 1036 | + throw new ParseException(msg, errorIndex); |
1035 | 1037 | } |
1036 | 1038 | return date; |
1037 | 1039 | } |
@@ -1129,6 +1131,6 @@ public String toString() { |
1129 | 1131 | */ |
1130 | 1132 | public String toStringAll() { |
1131 | 1133 | return "FastDateParser [pattern=" + pattern + ", timeZone=" + timeZone + ", locale=" + locale + ", century=" + century + ", startYear=" + startYear |
1132 | | - + ", patterns=" + patterns + "]"; |
| 1134 | + + ", patterns=" + StringUtils.join(patterns, ", " + System.lineSeparator() + "\t") + "]"; |
1133 | 1135 | } |
1134 | 1136 | } |
0 commit comments