Here you can find the source of stringToDate(String strDate, String formartStr)
public static Date stringToDate(String strDate, String formartStr)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date stringToDate(String strDate, String formartStr) { Date date = null;/*www.jav a 2 s . c om*/ if ((formartStr != null) && (!"".equals(formartStr))) { SimpleDateFormat sdf = new SimpleDateFormat(formartStr); try { date = sdf.parse(strDate); } catch (ParseException e) { date = null; e.printStackTrace(); } } return date; } }