List of utility methods to do Timestamp Create
Timestamp | toTimestamp(Date date) to Timestamp return toTimestamp(toLocalDateTime(date));
|
Timestamp | toTimestamp(Date date) Converts a Date to a Timestamp-object. Calendar cal = new GregorianCalendar(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return new Timestamp(cal.getTime().getTime()); |
Timestamp | toTimeStamp(Date date, String time) to Time Stamp Calendar cal = Calendar.getInstance(); cal.setLenient(true); boolean formatIs12 = time.endsWith("PM") || time.endsWith("AM"); String[] hhmmss = time.split(":"); if (hhmmss.length < 2) throw new IllegalArgumentException("invalid time"); if (hhmmss.length == 2) { String[] newTime = new String[3]; ... |
Timestamp | toTimestamp(DateTime dt) Null-safe method of converting a DateTime to a Timestamp. if (dt == null) { return null; } else { return new Timestamp(dt.getMillis()); |
Timestamp | toTimestamp(final Calendar cal) Converts a Calendar into a SQL timestamp. final Timestamp ts = new Timestamp(cal.getTimeInMillis()); return ts; |
Timestamp | toTimestamp(final Instant instant) TODO: Documentation return new Timestamp(instant.toEpochMilli()); |
Timestamp | toTimestamp(final int year, final int month, final int dayOfMonth, final int hour, final int minute, final int second, final int millsecond) to Timestamp Calendar cal = Calendar.getInstance(); cal.set(year, month - 1, dayOfMonth, hour, minute, second); cal.set(Calendar.MILLISECOND, millsecond); return new Timestamp(cal.getTimeInMillis()); |
Timestamp | toTimestamp(final java.sql.Date date) to Timestamp Timestamp ts = new Timestamp(date.getTime()); return ts; |
Timestamp | toTimestamp(final String pValue) Converts the string to a jdbc Timestamp, using the standard Timestamp escape format. return Timestamp.valueOf(pValue);
|
Timestamp | toTimestamp(java.sql.Date date) to Timestamp if (date == null) { return null; return new Timestamp(date.getTime()); |