Java Utililty Methods Timestamp Parse

List of utility methods to do Timestamp Parse

Description

The list of methods to do Timestamp Parse are organized into topic(s).

Method

TimestampstringToTimestamp(String sTimestamp)
string To Timestamp
Date d;
SimpleDateFormat stringToDate;
try {
    stringToDate = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.S");
    d = stringToDate.parse(sTimestamp);
} catch (ParseException e) {
    stringToDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
    d = stringToDate.parse(sTimestamp);
...
TimestampstringToTimestamp(String ts)
Conversion setting to 0 the nanoseconds, to deal with a mysql driver bug: nanoseconds value is not correct.
Timestamp t = Timestamp.valueOf(ts);
t.setNanos(0);
return t;
TimestampstringToTimestamp(String value)
string To Timestamp
try {
    return Timestamp.valueOf(value);
} catch (Exception e) {
    return new Timestamp(new java.util.Date().getTime());
TimestampstringToTimesTamp(String yMd, boolean isEndTime)
string To Times Tamp
if (yMd == null || yMd.length() == 0) {
    return null;
Timestamp ts = new Timestamp(System.currentTimeMillis());
StringBuffer buf = new StringBuffer();
buf.append(yMd);
if (isEndTime) {
    buf.append(" 23:59:59");
...
java.sql.TimestampstripToMinutes(java.sql.Timestamp timestamp)
Call this function to round off the second and millisecond of time.
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(timestamp.getTime());
int day = cal.get(Calendar.DATE);
int month = cal.get(Calendar.MONTH);
int year = cal.get(Calendar.YEAR);
int hour = cal.get(Calendar.HOUR_OF_DAY);
int time = cal.get(Calendar.MINUTE);
cal.clear();
...