Here you can find the source of stringConvertTimestamp(String time)
public static Timestamp stringConvertTimestamp(String time)
//package com.java2s; import java.sql.Timestamp; public class Main { public static Timestamp stringConvertTimestamp(String time) { if (null == time || "".equals(time)) { return null; }//from w w w. jav a 2s . com if (time.length() == 10) {// yyyy-MM-dd time = time + " 00:00:00.000000000"; } else if (time.length() == 16) {// yyyy-MM-dd hh:mm time = time + ":00.000000000"; } else if (time.length() == 19) {// yyyy-MM-dd hh:mm:dd time = time + ".000000000"; } return Timestamp.valueOf(time); } public static boolean equals(Timestamp t1, Timestamp t2) { if (t1 == null && t2 == null) { return true; } else { if (t1 == null) { return t2.equals(t1); } else { return t1.equals(t2); } } } }