Java Locale Format formatDuration(long nanoTime)

Here you can find the source of formatDuration(long nanoTime)

Description

format Duration

License

Open Source License

Declaration

private static String formatDuration(long nanoTime) 

Method Source Code


//package com.java2s;
/*//  ww  w .j a  v  a  2 s.  c om
 * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI for 
 * visualizing and manipulating spatial features with geometry and attributes.
 * Copyright (C) 2012  The JUMP/OpenJUMP contributors
 * 
 * This program is free software: you can redistribute it and/or modify it 
 * under the terms of the GNU General Public License as published by the Free 
 * Software Foundation, either version 2 of the License, or (at your option) 
 * any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along 
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;

public class Main {
    private static String formatDuration(long nanoTime) {
        double seconds = nanoTime / 1.0e9;
        DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US);
        DecimalFormat formatter = new DecimalFormat("0.000", symbols);
        return formatter.format(seconds);
    }
}

Related

  1. formatDouble(final Double value)
  2. formatDouble(Locale locale, double value)
  3. formatDouble(Number value)
  4. formatDouble(String pattern, double value)
  5. formatDoubleToCSV(double d)
  6. formatedDate(Date date)
  7. formatElapsedTime(double runTime)
  8. formatEn(T date, String pattern)
  9. formatFloat(float f, int numDecPlaces, boolean forceFractions)