Java Utililty Methods Timestamp Now

List of utility methods to do Timestamp Now

Description

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

Method

StringgenerateTimestamp()
Creates a properly formatted time stamp
return new SimpleDateFormat("MM/dd/yy HH:mm:ss.SSS").format(Calendar.getInstance().getTime());
StringgenerateTimestamp()
Generate the current datetimestamp in the string formaat (YYYYMMDDHHSS) required in a request to Realex.
return new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
TimestampgetAfterSecond(Timestamp currentDate)
get After Second
Calendar calender = Calendar.getInstance();
calender.setTime(currentDate);
calender.add(Calendar.SECOND, 1);
return new Timestamp(calender.getTimeInMillis());
StringgetCurrentAgeForDate(Timestamp birthDate, Timestamp endDate)
get Current Age For Date
if (birthDate != null) {
    long age = endDate.getTime() - birthDate.getTime();
    Date ageDate = new Date(age);
    Calendar calendar = new GregorianCalendar();
    calendar.setTime(ageDate);
    return String.valueOf(calendar.get(Calendar.YEAR) - EPIC);
return null;
...
TimestampgetCurrentDateAsTimestamp()
get Current Date As Timestamp
return floorAsDate(getCurrentTimestamp());
TimestampgetCurrentDateTimestamp()
get Current Date Timestamp
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Timestamp createDttm = Timestamp.valueOf(df.format(new java.util.Date()));
return createDttm;
TimestampgetCurrentDBTimestamp()
Method to return current db time in Timestamp formate
SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
String strDate = simple.format(new java.util.Date());
Timestamp timestamp = Timestamp.valueOf(strDate);
return timestamp;
java.sql.TimestampgetCurrentSQLTimestamp()
Gets the current SQL timestamp.
Calendar c = Calendar.getInstance();
java.sql.Timestamp t = new java.sql.Timestamp(c.getTimeInMillis());
return t;
java.sql.TimestampgetCurrentSQLTimestamp()
get current SQL Timestamp returns a date in following format: 2003-04-01 08:21:57.556
java.sql.Timestamp sqlTime = new java.sql.Timestamp(System.currentTimeMillis());
return sqlTime;
TimestampgetCurrentTimeStamp()
Produce an instance of Timestamp which can produce a string representation understood by Derby, and which reflects the current Date and Time.
final Calendar cal = new GregorianCalendar();
final Date currDate = cal.getTime();
return new Timestamp(currDate.getTime());