Java tutorial
//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 toDate(String template) { Date date = null; try { SimpleDateFormat inFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); date = inFormat.parse(template); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return date; } }