Here you can find the source of formatCharDateYMDHMS(String str)
public static Date formatCharDateYMDHMS(String str)
//package com.java2s; import java.sql.Date; import java.text.*; public class Main { public final static String DEFAULT_YMDHMSDATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static Date formatCharDateYMDHMS(String str) { String format = DEFAULT_YMDHMSDATE_FORMAT; if (str == null || str.trim().length() == 0) { return null; }// ww w . j ava 2 s . c om SimpleDateFormat sdf = new SimpleDateFormat(format); ParsePosition pos = new ParsePosition(0); java.util.Date date = sdf.parse(str, pos); if (date == null) { return null; } return new Date(date.getTime()); } }