Here you can find the source of parseStringToDate(final String pDate, final String... pFormat)
public static Date parseStringToDate(final String pDate, final String... pFormat)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String DEFAULT_FORMAT = "yyyy-MM-dd"; private static final int FORMAT_POSITION = 0; public static Date parseStringToDate(final String pDate, final String... pFormat) { final DateFormat dateFormat; if (pFormat.length == 0) { dateFormat = new SimpleDateFormat(DEFAULT_FORMAT); } else {/* w ww. j a v a 2s .c om*/ dateFormat = new SimpleDateFormat(pFormat[FORMAT_POSITION]); } final Date parsedDate; try { parsedDate = dateFormat.parse(pDate); } catch (ParseException pEx) { return null; } return parsedDate; } }