Java tutorial
//package com.java2s; import android.text.TextUtils; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date parse(String strDate, String pattern) { if (TextUtils.isEmpty(strDate)) { return null; } try { SimpleDateFormat df = new SimpleDateFormat(pattern); return df.parse(strDate); } catch (Exception e) { e.printStackTrace(); return null; } } }