Here you can find the source of stringToDate(String pstrValue, String pstrDateFormat)
public static java.util.Date stringToDate(String pstrValue, String pstrDateFormat)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; public class Main { /**/* w w w.ja v a2 s . c om*/ * Convert string to Date * * @return a java.util.Date object converted. */ public static java.util.Date stringToDate(String pstrValue, String pstrDateFormat) { if ((pstrValue == null) || (pstrValue.equals(""))) { return null; } java.util.Date dttDate = null; try { SimpleDateFormat oFormatter = new SimpleDateFormat(pstrDateFormat); dttDate = oFormatter.parse(pstrValue); oFormatter = null; } catch (Exception e) { return null; } return dttDate; } }