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 string2Date(String str, String format) { try { return new SimpleDateFormat(format).parse(str); } catch (ParseException e) { e.printStackTrace(); } return new Date(); } }