Here you can find the source of convertStringToDate(String s)
public static Date convertStringToDate(String s)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date convertStringToDate(String s) { try {/* w ww . jav a 2s.com*/ SimpleDateFormat dateformat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date d; d = dateformat1.parse(s); return d; } catch (ParseException e) { } try { SimpleDateFormat dateformat1 = new SimpleDateFormat("yyyy-MM-dd"); Date d; d = dateformat1.parse(s); return d; } catch (ParseException e) { } throw new RuntimeException("Date format:" + s + " is not supported"); } }