List of utility methods to do Timestamp
java.sql.Timestamp | createDateTimestamp(java.util.Date date) create Date Timestamp java.util.Calendar calendar = java.util.Calendar.getInstance(); calendar.setTime(date); return new java.sql.Timestamp((calendar.getTime()).getTime()); |
Timestamp | date2Timestamp(Date date) date Timestamp if (date == null) { return null; return new Timestamp(date.getTime()); |
Timestamp | date2Timestamp(Date value) date Timestamp if (value != null) { return new Timestamp(value.getTime()); return null; |
Timestamp | dateAdd(Timestamp t1, Integer i, int type) date Add long interval = i * 1000 * 60 * 60 * 24l; Timestamp t = null; switch (type) { case 1: interval = 1000 * 60 * 60 * i; t = new Timestamp(t1.getTime() + interval); break; case 2: ... |
Timestamp | dateAndTimeToTimestamp(Date data, Time hora) date And Time To Timestamp if (data != null) { Calendar calendarData = dateToCalendar(data); if (hora != null) { Calendar calendarHora = dateToCalendar(hora); calendarData.set(Calendar.HOUR_OF_DAY, calendarHora.get(Calendar.HOUR_OF_DAY)); calendarData.set(Calendar.MINUTE, calendarHora.get(Calendar.MINUTE)); calendarData.set(Calendar.SECOND, calendarHora.get(Calendar.SECOND)); calendarData.set(Calendar.MILLISECOND, calendarHora.get(Calendar.MILLISECOND)); ... |
Timestamp | dateIntToTimestamp(int dateInt) Converts an integer formatted to an instance of Timestamp
Calendar calendar = dateIntToCalendar(dateInt); return new Timestamp(calendar.getTimeInMillis()); |
boolean | datesDiffer(Timestamp a, Timestamp b) dates Differ if (a == null && b == null) { return false; if (a != null && b == null) { return true; if (a == null) { return true; ... |
Timestamp | dateStringToTimestamp(String dateStr) date String To Timestamp Timestamp ts = new Timestamp(System.currentTimeMillis()); dateStr += " 00:00:00"; try { ts = Timestamp.valueOf(dateStr); } catch (Exception e) { e.printStackTrace(); return ts; ... |
java.sql.Timestamp | datetime2ToTimestamp(long value, int fraction, int width) datetime To Timestamp final long millis = getMillisFromDatetime2(value); final java.sql.Timestamp r = new java.sql.Timestamp(millis); r.setNanos(nanosForFractionalValue(fraction, width)); return r; |
String | dateTimeToString(Timestamp dt, String df) DateTime convert to String. String pstrDate = null; if (dt == null) { return ""; String formatStyle = null; if ((df == null) || (df.equals(""))) { formatStyle = "yyyy-MM-dd HH:mm:ss"; } else { ... |