Here you can find the source of strToDate(String i_StrDate, String i_Format)
public static java.util.Date strToDate(String i_StrDate, String i_Format) throws ParseException
//package com.java2s; //License from project: Open Source License import java.text.*; public class Main { public static final SimpleDateFormat SDF_FULL = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static java.util.Date strToDate(String i_Today, String i_Hour, String i_Minute) { try {//from w ww . java 2 s . com if (i_Today == null || i_Hour == null || i_Minute == null) { return null; } return SDF_FULL.parse(i_Today.trim() + " " + i_Hour.trim() + ":" + i_Minute.trim() + ":00"); } catch (Exception e) { // e.printStackTrace(); } return null; } public static java.util.Date strToDate(String i_StrDate) { try { if (i_StrDate == null || "".equals(i_StrDate.trim())) { return null; } return SDF_FULL.parse(i_StrDate); } catch (Exception e) { // e.printStackTrace(); } return null; } public static java.util.Date strToDate(String i_StrDate, String i_Format) throws ParseException { SimpleDateFormat SDF_My = new SimpleDateFormat(i_Format); try { return SDF_My.parse(i_StrDate); } catch (ParseException e) { throw e; } } public static java.util.Date strToDate(String i_StrDate, SimpleDateFormat i_SDF) throws ParseException { try { return i_SDF.parse(i_StrDate); } catch (ParseException e) { throw e; } } }