Java Timestamp Field getPerformanceTime(Timestamp startTime)

Here you can find the source of getPerformanceTime(Timestamp startTime)

Description

Gets the performance time.

License

Open Source License

Parameter

Parameter Description
startTime the start time

Return

the performance time

Declaration

public static String getPerformanceTime(Timestamp startTime) 

Method Source Code


//package com.java2s;
import java.sql.Timestamp;

public class Main {
    /**//from   ww w  . j av  a  2  s . c om
     * Gets the performance time.
     * 
     * @param startTime
     *            the start time
     * @return the performance time
     */
    public static String getPerformanceTime(Timestamp startTime) {
        return getTimeDifference(startTime, new Timestamp(System.currentTimeMillis()));
    }

    /**
     * Gets the time difference.
     * 
     * @param startTime
     *            the start time
     * @param endTime
     *            the end time
     * @return the time difference
     */
    public static String getTimeDifference(Timestamp startTime, Timestamp endTime) {
        long timeInMilliseconds = endTime.getTime() - startTime.getTime();
        int seconds = (int) (timeInMilliseconds / 1000);
        int minutes = seconds / 60;
        int milliseconds = (int) (timeInMilliseconds % 1000);
        return minutes + " minute(s) " + seconds + " second(s) " + milliseconds + " millisecond(s)";
    }
}

Related

  1. getNotNullTimestampValue(String timestamp, String format)
  2. getNowTimestamp()
  3. getNowTimeStamp()
  4. getNowTimeStamp()
  5. getOffsetDaysTime(Timestamp sysDate, int offsetDays)
  6. getPeriodExpiration(Timestamp tsStartDate, int iPeriodType, int iPeriodDuration)
  7. getPresentTimeStamp()
  8. getRandomTimeBetweenTwoDates(Timestamp beginDate, Map context)
  9. getRandTimestamp(Random r)