From 192b1e1b6b96da05cb000b2c89b71467cbfaf245 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Thu, 27 Sep 2012 00:02:58 +0000 Subject: [PATCH] Allow access to parsedPattern for test purposes Make ParseException text similar to that thrown by SimpleDateFormat git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1390778 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/commons/lang3/time/FastDateParser.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java index 49d93dcec..a01159bdb 100644 --- a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java +++ b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java @@ -175,6 +175,11 @@ public class FastDateParser implements DateParser, Serializable { return locale; } + // Give access to generated pattern for test code + Pattern getParsePattern() { + return parsePattern; + } + // Basics //----------------------------------------------------------------------- /** @@ -248,9 +253,9 @@ public class FastDateParser implements DateParser, Serializable { if (locale.equals(JAPANESE_IMPERIAL)) { throw new ParseException( "(The " +locale + " locale does not support dates before 1868 AD)\n" + - source+" does not match "+parsePattern.pattern(), 0); + "Unparseable date: \""+source+"\" does not match "+parsePattern.pattern(), 0); } - throw new ParseException(source+" does not match "+parsePattern.pattern(), 0); + throw new ParseException("Unparseable date: \""+source+"\" does not match "+parsePattern.pattern(), 0); } return date; }