Here you can find the source of stringToDateByconf(String str, String formate)
public static Date stringToDateByconf(String str, String formate)
//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 { public static Date stringToDateByconf(String str, String formate) { DateFormat formater;//from www . ja va 2s . c om formater = new SimpleDateFormat(formate); try { return (Date) formater.parse(str); } catch (ParseException e) { // TODO Auto-generated catch block formater = new SimpleDateFormat("yyyy-MM-dd"); try { return (Date) formater.parse(str.substring(0, 10)); } catch (ParseException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } return new Date(); } }