List of utility methods to do Timestamp
long | calcRealTime(Timestamp beginTime, Timestamp endTime) calc Real Time Calendar beginC = getRealCalendar(beginTime); Calendar endC = getRealCalendar(endTime); long span = (endC.getTimeInMillis() - beginC.getTimeInMillis()) / 1000; long a = span / (86400 * 7); long b = span % (86400 * 7); long c = b / 86400; long d = b % 86400; if (endC.get(Calendar.DAY_OF_WEEK) < beginC.get(Calendar.DAY_OF_WEEK) ... |
Timestamp | calendar2Timestamp(Calendar c) calendar Timestamp return new Timestamp(c.getTimeInMillis()); |
java.sql.Timestamp | calendarToTimestamp(java.util.Calendar inCal) Returns Timestamp converted from Calendar. if (inCal == null) { return (null); java.sql.Timestamp time = new java.sql.Timestamp(inCal.getTime().getTime()); return (time); |
Timestamp | calToTimeStamp(Calendar cal) cal To Time Stamp Timestamp tm = null; if (cal == null) { tm = null; } else { tm = new Timestamp(cal.getTime().getTime()); return tm; |
Timestamp | changeDate(Timestamp date, Integer amount, Integer unit) Increments/decrements the specified timestamp by the amount and unit. Calendar c; if (date == null || amount == 0) return date; c = Calendar.getInstance(); c.setTimeInMillis(date.getTime()); c.add(unit, amount); return new Timestamp(c.getTimeInMillis()); |
Timestamp | checkTimestamp(String sval) Timestamp type validation and conversion. Calendar cal = Calendar.getInstance(); cal.set(2000, 0, 1); Timestamp tval = new Timestamp(cal.getTime().getTime()); try { tval = new Timestamp(ALUDB_DF.parse(sval).getTime()); } catch (ParseException pe) { System.err.println("Timestamp parse exception, def to '2000-01-01' :: " + pe); } catch (NumberFormatException nfe) { ... |
Timestamp | clone(Timestamp original) Clone a Timestamp because they are mutable return original == null ? null : (Timestamp) original.clone();
|
Timestamp | concatDateAndTime(Timestamp date, Time time) Concats date with time to call the overloaded changeDate method: Calendar c; if (date == null || time == null) return date; c = Calendar.getInstance(); c.setTimeInMillis(date.getTime()); c.set(Calendar.HOUR_OF_DAY, time.getHours()); c.set(Calendar.MINUTE, time.getMinutes()); c.set(Calendar.SECOND, time.getSeconds()); ... |
String | convertTS2HHMM(Timestamp timeStamp) RBC CMD 1.0 This method is used to Convert Timestamp to HHMM(HoursMinutes) return onlyHHMM.format(timeStamp);
|
Timestamp | copyOrCreateTimestampNullsafe(Date date) copy Or Create Timestamp Nullsafe return date == null ? new Timestamp(System.currentTimeMillis()) : new Timestamp(date.getTime()); |