Here you can find the source of getFormattedHoursAndMinutes(final long millis)
Parameter | Description |
---|---|
millis | a parameter |
public static String getFormattedHoursAndMinutes(final long millis)
//package com.java2s; // ProjectForge is dual-licensed. public class Main { /**/*w w w . java 2s . c o m*/ * @param millis * @return hours:minutes (e. g. 2:30, 12:30, 127:15, ...) */ public static String getFormattedHoursAndMinutes(final long millis) { final long seconds = millis / 60000; final int hours = (int) seconds / 60; final int minutes = (int) seconds % 60; final StringBuilder buf = new StringBuilder(); buf.append(hours).append(":"); // hours formatNumber(buf, minutes); // minutes return buf.toString(); } private static void formatNumber(final StringBuilder buf, final long number) { if (number < 10) { buf.append("0"); } buf.append(number); } }