Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date formatStringToDate(String str) { Date date = null; try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); date = simpleDateFormat.parse(str); } catch (Exception e) { e.printStackTrace(); } return date; } }