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

StringgetTimeStamp()
Create logfile TimeStamp
Timestamp ts = new Timestamp((new Date()).getTime());
String strTime = String.valueOf(ts.getTime());
if (strTime.length() > 10) {
    strTime = strTime.substring(0, 10);
return strTime;
StringgetTimestamp()
Get the TimeStamp like 2009-06-01T06:12:45Z
return formatTimeStamp(new Timestamp(new Date().getTime()));
TimestampgetTimestamp()
get Timestamp
Date utilDate = new Date();
Timestamp sq = new Timestamp(utilDate.getTime());
System.out.println(sq);
return sq;
TimestampgetTimeStamp()
get Time Stamp
String d = new SimpleDateFormat(TIME_FORMAT).format(Calendar.getInstance().getTime());
return Timestamp.valueOf(d);
StringgetTimestamp()
Accessor method to return current time as a yyyy-MM-dd hh:mm:ss.SSS string (aka SQL TIMESTAMP format)
long date = (new Date()).getTime();
return (new Timestamp(date)).toString();
TimestampgetTimeStamp()
get Time Stamp
java.util.Date now = new java.util.Date();
return new java.sql.Timestamp(now.getTime());
TimestampgetTimestamp()
get Timestamp
Timestamp ts = new Timestamp(getDate("yyyy-MM-dd HH:mm:ss").getTime());
return ts;
DategetTimestamp()
get Timestamp
return new java.sql.Timestamp(Calendar.getInstance().getTime().getTime());
booleanisCurrentDataByStartdataAndEnddata(Timestamp startDate, Timestamp endDate)
the method's result was used decsion isCurrentDate by startDate and endDate
boolean result = false;
Timestamp currentDate = getCurrentTimestamp();
if (endDate == null) {
    if (currentDate.compareTo(startDate) >= 0) {
        result = true;
} else {
    if ((currentDate.compareTo(startDate)) >= 0 && (currentDate.compareTo(endDate)) <= 0) {
...
TimestampnowTimestamp()
now Timestamp
Long now = System.nanoTime();
Timestamp value = new Timestamp(now / 1_000_000L);
value.setNanos(Long.valueOf(now % 1_000_000_000L).intValue());
return value;