Java Utililty Methods Timestamp Field

List of utility methods to do Timestamp Field

Description

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

Method

longgetRandomTimeBetweenTwoDates(Timestamp beginDate, Map context)
Method should generate random number that represents a time between two dates.
long beginTime, endTime;
Calendar cal = Calendar.getInstance();
if (context.get("maxDate") != null) {
    endTime = ((Timestamp) context.get("maxDate")).getTime();
} else {
    endTime = cal.getTimeInMillis();
if (beginDate != null) {
...
TimestampgetRandTimestamp(Random r)
get Rand Timestamp
return getRandTimestamp(r, MIN_YEAR, MAX_YEAR);
CalendargetRealCalendar(Timestamp time)
get Real Calendar
Calendar c = Calendar.getInstance();
c.setTimeInMillis(time.getTime());
if (c.get(Calendar.DAY_OF_WEEK) == 6 && c.get(Calendar.HOUR_OF_DAY) >= 19) {
    c.setTimeInMillis(c.getTimeInMillis() + 86400000 * 3);
    clearTime(c);
    return c;
if (c.get(Calendar.DAY_OF_WEEK) == 7) {
...
TimestampgetResultRowValueAsTimestamp(String valueName, Map resultRow)
get Result Row Value As Timestamp
return (Timestamp) resultRow.get(valueName);
longgetSafeLong(final Timestamp d, final long i)
get Safe Long
return d == null ? i : d.getTime();
intgetSeconds(Timestamp timeStamp)
get Seconds
return timeStamp == null ? 0 : (int) (timeStamp.getTime() / 1000);
StringgetServerToUserDateString(TimeZone timeZone, int dateFormat, java.sql.Timestamp date)
Gets the serverToUserDateString attribute of the DateUtils class
SimpleDateFormat formatter = null;
try {
    formatter = (SimpleDateFormat) SimpleDateFormat.getDateInstance(dateFormat);
    formatter.applyPattern("M/d/yyyy");
    formatter.setTimeZone(timeZone);
} catch (Exception e) {
    System.err.println("EXCEPTION: DateUtils -> Timestamp " + date);
return formatter.format((java.util.Date) date);
TimestampgetSqlTimeStamp()
get Sql Time Stamp
java.sql.Date date = new java.sql.Date(System.currentTimeMillis());
Timestamp timestamp = new Timestamp(date.getTime());
return timestamp;
java.sql.TimestampgetSqlTimeStamp(java.util.Date date)
Get java.sql.Timestamp from java.util.Date
Calendar cal = Calendar.getInstance();
cal.setTime(date);
return new java.sql.Timestamp(cal.getTimeInMillis());
TimestampgetSQLTimeStampForDate(Date date)
get SQL Time Stamp For Date
if (date == null)
    return null;
return new Timestamp(date.getTime());