Here you can find the source of toDateByFormat(String dateString, String formatStr)
public static Date toDateByFormat(String dateString, String formatStr)
//package com.java2s; /*/*from www . jav a 2s .co m*/ * BJAF - Beetle J2EE Application Framework * ???J2EE??????????? * ??????2003-2015 ??? (www.beetlesoft.net) * * ?????????????????? *<http://www.apache.org/licenses/LICENSE-2.0> *???????????????????????? * * ??????????????????????????????? * ??? <yuhaodong@gmail.com/>. */ import java.text.ParseException; import java.util.Date; public class Main { public static Date toDateByFormat(String dateString, String formatStr) { java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(formatStr); try { return sdf.parse(dateString); } catch (ParseException ex) { ex.printStackTrace(); return null; } } }