Java Timestamp Field getDiffTime(Timestamp last)

Here you can find the source of getDiffTime(Timestamp last)

Description

get Diff Time

License

Open Source License

Declaration

public static long getDiffTime(Timestamp last) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.sql.Timestamp;

import java.util.Date;

public class Main {
    public static long getDiffTime(Timestamp last) {
        Date date = new Date();
        Timestamp now = new Timestamp(date.getTime());

        long nowSec = now.getTime() / 1000;
        long lastSec = last.getTime() / 1000;
        if (nowSec > lastSec) {
            return nowSec - lastSec;
        } else {//from  w  w w. j a v a 2s  . c  o  m
            return lastSec - nowSec;
        }
    }
}

Related

  1. getDayTime(Timestamp day, Timestamp time)
  2. getDefaultTimestamp()
  3. getDiffDay(Timestamp time1, Timestamp time2)
  4. getDifferenceInHours(Timestamp startDateTime, Timestamp endDateTime)
  5. getDiffSecond(long orgTimestamp, long desTimestamp)
  6. getDiffYear(java.sql.Timestamp start, java.sql.Timestamp end)
  7. getDiscrepancyNum(Timestamp time1, Timestamp time2)
  8. getDouble(Timestamp ts)
  9. getDuration(final Timestamp start, final Date end)