Java Second Format getElapsedSeconds(long startTime)

Here you can find the source of getElapsedSeconds(long startTime)

Description

get Elapsed Seconds

License

Open Source License

Return

Pretty print elapsed time in seconds, rounded to 2 decimal places, eg "2.34s"

Declaration

public static String getElapsedSeconds(long startTime) 

Method Source Code

//package com.java2s;
/*!//from   ww  w.  j  a va2 s .  com
* Copyright 2002 - 2017 Webdetails, a Hitachi Vantara company.  All rights reserved.
* 
* This software was developed by Webdetails and is provided under the terms
* of the Mozilla Public License, Version 2.0, or any later version. You may not use
* this file except in compliance with the license. If you need a copy of the license,
* please go to  http://mozilla.org/MPL/2.0/. The Initial Developer is Webdetails.
*
* Software distributed under the Mozilla Public License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to
* the license for the specific language governing your rights and limitations.
*/

import java.text.DecimalFormat;

public class Main {
    public static final DecimalFormat DEFAULT_DURATION_FORMAT_SEC = new DecimalFormat("0.00s");

    /**
     * @return Pretty print elapsed time in seconds, rounded to 2 decimal places, eg "2.34s"
     */
    public static String getElapsedSeconds(long startTime) {
        return DEFAULT_DURATION_FORMAT_SEC.format((System.currentTimeMillis() - startTime) / 1000.0);
    }
}

Related

  1. formatTimeInSeconds(int v)
  2. formatTimeSecondsSinceEpoch(final long time, StringBuilder sbuffer)
  3. formatTimeSpanSeconds(long span)
  4. formatTimeWithOutSeconds(java.util.Date d)
  5. getDHMS(long totalSecond)
  6. getFormatMSecond(long long_)
  7. getFormattedDuration(int simTimeSeconds)
  8. getFullDateByMisSecond(long misSecond)
  9. getFutureDate(int seconds)