Java tutorial
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date string2date(String date, String format) { try { SimpleDateFormat sdf = new SimpleDateFormat(format); Date result = sdf.parse(date); sdf = null; return result; } catch (Exception e) { e.printStackTrace(); return null; } } public static Date string2date(String date) { return string2date(date, "yyyy-MM-dd"); } }