Here you can find the source of formatFromString(String date)
public static Date formatFromString(String date)
//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 formatFromString(String date) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try {// w w w .j a v a 2 s. co m return sdf.parse(date); } catch (ParseException e) { // e.printStackTrace(); } return null; } }