Here you can find the source of strToTimestamp(String i_Today, String i_Hour, String i_Minute)
public static Timestamp strToTimestamp(String i_Today, String i_Hour, String i_Minute)
//package com.java2s; //License from project: Open Source License import java.sql.*; import java.text.*; public class Main { public static final SimpleDateFormat SDF_FULL = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static Timestamp strToTimestamp(String i_Today, String i_Hour, String i_Minute) { try {/*from w ww . ja va2s . com*/ if (i_Today == null || i_Hour == null || i_Minute == null) { return null; } java.util.Date d = strToDate(i_Today, i_Hour, i_Minute); return new java.sql.Timestamp(d.getTime()); } catch (Exception e) { // e.printStackTrace(); } return null; } public static Timestamp strToTimestamp(String i_StrDate) { try { if (i_StrDate == null || "".equals(i_StrDate)) { return null; } java.util.Date v_Date = strToDate(i_StrDate); return new java.sql.Timestamp(v_Date.getTime()); } catch (Exception e) { e.printStackTrace(); } return null; } public static java.util.Date strToDate(String i_Today, String i_Hour, String i_Minute) { try { 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; } } }