Here you can find the source of stringToDate(String strDate, String pattern)
public static Date stringToDate(String strDate, String pattern)
//package com.java2s; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final SimpleDateFormat DB_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss"); public static Date stringToDate(String strDate, String pattern) { Date date = null;/*from ww w .jav a2s. com*/ DateFormat df = new SimpleDateFormat(pattern); try { date = df.parse(strDate); } catch (ParseException e) { return null; } return date; } public static Date parse(Long date) { try { return DB_FORMAT.parse(String.valueOf(date)); } catch (ParseException e) { return null; } } }