Here you can find the source of strToDate(String input, String format)
public static Date strToDate(String input, String format)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date strToDate(String input, String format) { try {/*from w w w.j a va 2 s . co m*/ SimpleDateFormat df = new SimpleDateFormat(format); return df.parse(input); } catch (Exception e) { return null; } } }