Java tutorial
//package com.java2s; import java.sql.Date; import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { /** * String to date. e.g. 2013-12-13 * * @param dateStr * @return */ public static Date str2Date(String dateStr) { try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(sdf.parse(dateStr).getTime()); sdf = null; return date; } catch (ParseException e) { return null; } } }