List of utility methods to do Timestamp Create
java.sql.Timestamp | getTimestamp(Object value) Convert an Object to a Timestamp, without an Exception try { return toTimestamp(value); } catch (ParseException pe) { pe.printStackTrace(); return null; |
java.sql.Timestamp | getTimestamp(Object value, int columnType) get Timestamp if (value == null) { return null; switch (columnType) { case java.sql.Types.TIMESTAMP: { return (java.sql.Timestamp) value; case java.sql.Types.TIME: { ... |
Timestamp | getTimestamp(ResultSet rs, String colName) Returns the TimeStamp value for the specified column if (colName == null || colName.length() == 0 || rs == null) { throw new IllegalArgumentException("getTimestamp: one or more parameters are null"); Timestamp timestamp = rs.getTimestamp(colName); if (rs.wasNull()) { return null; return timestamp; ... |
Timestamp | getTimestamp(ResultSet rs, String strColName) Auxiliary method to avoid problems with null timestamp values Timestamp value = rs.getTimestamp(strColName);
return rs.wasNull() ? null : value;
|
Timestamp | getTimestamp(String date, String time) get Timestamp Calendar c = dateToCalendar(date); c.set(Calendar.HOUR_OF_DAY, atoi(time.substring(0, 2))); c.set(Calendar.MINUTE, atoi(time.substring(2, 4))); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return new Timestamp(c.getTimeInMillis()); |
Timestamp | getTimestamp(String dateStr) get Timestamp try { SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy kk:mm:ss"); Timestamp date = new Timestamp(dateFormat.parse(dateStr).getTime()); return date; } catch (Exception ex) { System.out.println("Error: " + ex.toString()); return null; |
Timestamp | getTimestamp(String dateString, String format) get Timestamp Date date = getDate(dateString, format); if (date == null) return null; return new Timestamp(date.getTime()); |
long | getTimestamp(String sqlDateTime) get Timestamp return Timestamp.valueOf(sqlDateTime).getTime();
|
Timestamp | getTimestamp(String str) get Timestamp try { if (str == null || str.equals("")) { return null; if (str.length() == 10) { DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd"); java.util.Date tempDate = df.parse(str); return new java.sql.Timestamp(tempDate.getTime()); ... |
Timestamp | getTimestamp(String Str) get Timestamp Timestamp time = null; try { time = java.sql.Timestamp.valueOf(Str); } catch (Exception e) { System.out.println("getTimestamp error:" + e); return time; |