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

java.sql.TimestampgetNextDayStart(java.sql.Timestamp stamp)
get Next Day Start
return getDayStart(stamp, 1);
TimestampgetNextTimestamp(Timestamp previous, long nrDays)
get Next Timestamp
return new Timestamp(previous.getTime() + (nrDays * 24 * 60 * 60 * 1000));
TimestampgetNotNullTimestampValue(String timestamp, String format)
get Not Null Timestamp Value
Timestamp value;
try {
    if (timestamp == null || timestamp.equals("")) {
        value = new Timestamp(System.currentTimeMillis());
    } else {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
        value = new Timestamp(simpleDateFormat.parse(timestamp).getTime());
} catch (Exception e) {
    e.printStackTrace();
    value = new Timestamp(System.currentTimeMillis());
return value;
java.sql.TimestampgetNowTimestamp()
get Now Timestamp
Calendar cal1 = Calendar.getInstance();
return new java.sql.Timestamp(cal1.getTimeInMillis());
longgetNowTimeStamp()
get Now Time Stamp
long returnTimeStamp = 0;
Date aDate = null;
try {
    aDate = convertStringToDate("yyyy-MM-dd HH:mm:ss", getNowDateTime());
} catch (ParseException pe) {
    aDate = null;
if (aDate == null) {
...
TimestampgetNowTimeStamp()
get Now Time Stamp
return new Timestamp(getNow().getTime());
TimestampgetOffsetDaysTime(Timestamp sysDate, int offsetDays)
get Offset Days Time
Calendar calendar = Calendar.getInstance();
calendar.setTime(sysDate);
calendar.add(Calendar.DAY_OF_MONTH, offsetDays);
return new Timestamp(calendar.getTimeInMillis());
StringgetPerformanceTime(Timestamp startTime)
Gets the performance time.
return getTimeDifference(startTime, new Timestamp(System.currentTimeMillis()));
TimestampgetPeriodExpiration(Timestamp tsStartDate, int iPeriodType, int iPeriodDuration)
Get expiration timestamp from start date, period type and duration.
Timestamp tsReturn = null;
Calendar calHelp;
if (tsStartDate != null && iPeriodDuration > 0 && iPeriodType > TIMING_NEVER && iPeriodType < TIMING_NONE) {
    calHelp = Calendar.getInstance();
    calHelp.setTime(tsStartDate);
    switch (iPeriodType) {
    case (TIMING_MINUTES): {
        calHelp.add(Calendar.MINUTE, iPeriodDuration);
...
TimestampgetPresentTimeStamp()
get Present Time Stamp
Timestamp ts = null;
java.util.Date d = new java.util.Date();
ts = new Timestamp(d.getTime());
return ts;