Java Time Format formatCooldown(long time)

Here you can find the source of formatCooldown(long time)

Description

format Cooldown

License

GNU General Public License

Declaration

public static String formatCooldown(long time) 

Method Source Code

//package com.java2s;
/*/*from w  w  w.j a va 2s  .  co m*/
 * ItemHelper.java
 * Source: Equivalent Exchange 3 by Pahimar
 * License: GPLv3
 * 
 */

public class Main {
    public static String formatCooldown(long time) {
        long hours = time / 3600;
        long minutes = (time % 3600) / 60;
        long seconds = time % 60;
        String currentCooldown = "";
        if (hours > 0) {
            currentCooldown = String.format("%dh %dm %ds", hours, minutes, seconds);
        } else if (minutes > 0) {
            currentCooldown = String.format("%dm %ds", minutes, seconds);
        } else {
            currentCooldown = String.format("%ds", seconds);
        }
        return currentCooldown;
    }
}

Related

  1. format(long time)
  2. format(long time)
  3. format(long time, String timerPrecisionId, boolean round)
  4. format(String format, long time)
  5. formatBenchResult(final String benchName, final int iterationCount, final int benchNumber, final double benchTime)
  6. formatDateTime(String DateTimeStr)
  7. formatDateTime(String s)
  8. formatDateTime(String value)
  9. formatDateTimeString(final String dateTimeString, final boolean wrapForCodeUsage)