git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@905267 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Niall Pemberton 2010-02-01 12:00:11 +00:00
parent 1c5b51d6a6
commit 381cb097a8
1 changed files with 15 additions and 0 deletions

View File

@ -306,6 +306,21 @@ public class DateUtils {
return parseDateWithLeniency(str, parsePatterns, false);
}
/**
* <p>Parses a string representing a date by trying a variety of different parsers.</p>
*
* <p>The parse will try each parse pattern in turn.
* A parse is only deemed successful if it parses the whole of the input string.
* If no parse patterns match, a ParseException is thrown.</p>
*
* @param str the date to parse, not null
* @param parsePatterns the date format patterns to use, see SimpleDateFormat, not null
* @param lenient Specify whether or not date/time parsing is to be lenient.
* @return the parsed date
* @throws IllegalArgumentException if the date string or pattern array is null
* @throws ParseException if none of the date patterns were suitable
* @see java.util.Calender#isLenient()
*/
private static Date parseDateWithLeniency(String str, String[] parsePatterns,
boolean lenient) throws ParseException {
if (str == null || parsePatterns == null) {