Here you can find the source of getDateFromString(String dateStr, String pattern)
public static Date getDateFromString(String dateStr, String pattern)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date getDateFromString(String dateStr, String pattern) { SimpleDateFormat sdf = new SimpleDateFormat(pattern); Date resDate = null;/*from w ww . ja va 2s . com*/ try { resDate = sdf.parse(dateStr); } catch (Exception e) { e.printStackTrace(); } return resDate; } }