Java Second Format formatSecondFractions(long numUnits, int denominator)

Here you can find the source of formatSecondFractions(long numUnits, int denominator)

Description

format Second Fractions

License

Open Source License

Parameter

Parameter Description
numUnits a parameter

Declaration

public static String formatSecondFractions(long numUnits, int denominator) 

Method Source Code

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

public class Main {
    /**/*  w  w w .jav  a 2s. com*/
     *
     * @param numUnits
     * @return
     */
    public static String formatSecondFractions(long numUnits, int denominator) {
        if (numUnits == 0) {
            return "0:00:00";
        }

        StringBuffer timeStr = new StringBuffer(10);
        //        long deciSeconds = (numMicroseconds / denominator ) % 10;
        long seconds = (numUnits / denominator) % 60;
        long minutes = (numUnits / denominator / 60) % 60;
        long hours = (numUnits / denominator / 60 / 60);
        timeStr.append(hours);
        timeStr.append(":");
        if (minutes < 10) {
            timeStr.append("0").append(minutes);
        } else {
            timeStr.append(minutes);
        }
        timeStr.append(":");
        if (seconds < 10) {
            timeStr.append("0").append(seconds);
        } else {
            timeStr.append(seconds);
        }
        //        timeStr.append(".");
        //        timeStr.append(deciSeconds);
        return timeStr.toString();
    }
}

Related

  1. elapsedSeconds2(long milli)
  2. formatMiliSeconds(long time)
  3. formatMilliIntervalAsSeconds(long interval)
  4. formatMinutesSeconds(final long sourceDuration, final TimeUnit sourceUnit)
  5. formatNanoseconds (final long ns)
  6. formatSeconds(double seconds)
  7. formatSeconds(double seconds)
  8. formatSeconds(double seconds, int precision)
  9. formatSeconds(double value)