Here you can find the source of convertDateStringToDate(String dateString, String format)
public static Date convertDateStringToDate(String dateString, String format)
//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 convertDateStringToDate(String dateString) { return convertDateStringToDate(dateString, "yyyy-MM-dd HH:mm:ss"); }//from www . j a v a 2 s.c o m public static Date convertDateStringToDate(String dateString, String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); Date date = null; try { date = sdf.parse(dateString); } catch (ParseException e) { e.printStackTrace(); } return date; } }