Here you can find the source of formatStrToDate(String value, String pattern)
public static java.util.Date formatStrToDate(String value, String pattern)
//package com.java2s; //License from project: Apache License import java.text.ParseException; public class Main { public static java.util.Date formatStrToDate(String value, String pattern) { java.text.SimpleDateFormat format = null; if (null == pattern) { format = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); } else {/* ww w . ja v a2 s . c o m*/ format = new java.text.SimpleDateFormat(pattern); } try { return format.parse(value); } catch (ParseException e) { e.printStackTrace(); } return null; } }