Here you can find the source of parseDate(String value, String[] parsePatterns)
public static Date parseDate(String value, String[] parsePatterns) throws ParseException
//package com.java2s; import java.text.ParseException; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date parseDate(String value, String[] parsePatterns) throws ParseException { if (value == null || parsePatterns == null) { throw new IllegalArgumentException( "Date and Patterns must not be null"); }/*ww w .j a v a 2s. c o m*/ SimpleDateFormat parser = null; ParsePosition pos = new ParsePosition(0); for (int i = 0; i < parsePatterns.length; i++) { if (i == 0) { parser = new SimpleDateFormat(parsePatterns[0]); } else { parser.applyPattern(parsePatterns[i]); } pos.setIndex(0); Date date = parser.parse(value, pos); if (date != null && pos.getIndex() == value.length()) { return date; } } throw new ParseException("Unable to parse the date: " + value, -1); } }