Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; public class Main { public static java.util.Date getDateByForm(String str, String dateform) { if (str == null || dateform == null) return null; SimpleDateFormat sdf = new SimpleDateFormat(dateform); try { java.util.Date date = sdf.parse(str); return date; } catch (Exception e) { return null; } } }