Here you can find the source of stringToDate(String str)
public synchronized static Date stringToDate(String str)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { static SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); public synchronized static Date stringToDate(String str) { if (isBlank(str)) { return null; }/*from ww w . j av a 2s. co m*/ try { return format.parse(str); } catch (ParseException e) { return null; } } /** * * @param str * @return */ public static boolean isBlank(String str) { if (str == null || str.trim().length() == 0) { return true; } return false; } }