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

booleanisDST(Timestamp ts)
Whether we are in DST for a particular time in the servers default timezone.
return !DateTimeZone.getDefault().isStandardOffset(ts.getTime());
booleanisInPast(Timestamp timeStamp)
is In Past
return timeStamp.getTime() < System.currentTimeMillis();
booleanisLongDate(Timestamp date)
Tells whether Timestamp is in long format: with hours, minutes and seconds fields.
return date.toString().indexOf("00:00:00") == -1;
booleanisLongTerm(Timestamp oldTime, Timestamp newTime)
is Long Term
long delta = Math.abs(newTime.getTime() - oldTime.getTime());
int days = (int) (delta / (1000 * 60 * 60 * 24));
if (days >= 365) {
    return true;
return false;
booleanisSameDay(Timestamp one, Timestamp two)
Is it the same day
GregorianCalendar calOne = new GregorianCalendar();
calOne.setTimeInMillis(one.getTime());
GregorianCalendar calTwo = new GregorianCalendar();
calTwo.setTimeInMillis(two.getTime());
if (calOne.get(Calendar.YEAR) == calTwo.get(Calendar.YEAR)
        && calOne.get(Calendar.MONTH) == calTwo.get(Calendar.MONTH)
        && calOne.get(Calendar.DAY_OF_MONTH) == calTwo.get(Calendar.DAY_OF_YEAR))
    return true;
...
booleanisSameMonth(Timestamp t1, Timestamp t2)
is Same Month
Calendar cal = Calendar.getInstance();
cal.setTime(t1);
int year1 = cal.get(Calendar.YEAR);
int month1 = cal.get(Calendar.MONTH);
System.out.println("year1:" + year1 + "month1:" + month1);
cal.setTime(t2);
int year2 = cal.get(Calendar.YEAR);
int month2 = cal.get(Calendar.MONTH);
...
booleanIsTechStatisticWorkTime(Timestamp timestamp)
Is Tech Statistic Work Time
try {
    int weekDay = getDayOfWeek(timestamp);
    if (weekDay >= 1 && weekDay <= 5) {
        if ((timestamp.getHours() >= 8 && timestamp.getHours() < 22)) {
            return true;
    } else {
        if (((timestamp.getHours() >= 10)) && timestamp.getHours() < 19) {
...
booleanisTimeStamp(Class o)
is Time Stamp
return o.toString().equals("class java.sql.Timestamp");
booleanisTimestamp(String aS_DateTime, String aS_Format)
Checks if datetime is aS_DateTime is same as in aS_Format
return stringToTimestamp(aS_DateTime, aS_Format, null, null) != null;
booleanisTimestamp(String str)
is Timestamp
try {
    @SuppressWarnings("unused")
    Date d = java.sql.Date.valueOf(str);
    return true;
} catch (Exception e) {
return false;