Java Utililty Methods Timestamp

List of utility methods to do Timestamp

Description

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

Method

longcalcRealTime(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)
...
Timestampcalendar2Timestamp(Calendar c)
calendar Timestamp
return new Timestamp(c.getTimeInMillis());
java.sql.TimestampcalendarToTimestamp(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);
TimestampcalToTimeStamp(Calendar cal)
cal To Time Stamp
Timestamp tm = null;
if (cal == null) {
    tm = null;
} else {
    tm = new Timestamp(cal.getTime().getTime());
return tm;
TimestampchangeDate(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());
TimestampcheckTimestamp(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) {
...
Timestampclone(Timestamp original)
Clone a Timestamp because they are mutable
return original == null ? null : (Timestamp) original.clone();
TimestampconcatDateAndTime(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());
...
StringconvertTS2HHMM(Timestamp timeStamp)
RBC CMD 1.0 This method is used to Convert Timestamp to HHMM(HoursMinutes)
return onlyHHMM.format(timeStamp);
TimestampcopyOrCreateTimestampNullsafe(Date date)
copy Or Create Timestamp Nullsafe
return date == null ? new Timestamp(System.currentTimeMillis()) : new Timestamp(date.getTime());