Here you can find the source of formatTime(final long time)
Parameter | Description |
---|---|
time | time in milliseconds |
public static String formatTime(final long time)
//package com.java2s; public class Main { /**/*from www .jav a 2 s . c o m*/ * @param time * time in milliseconds * @return Time formatted as X hours Y minutes Z seconds */ public static String formatTime(final long time) { long seconds = time / 1000; final long hours = seconds / 3600; final long minutes = (seconds % 3600) / 60; seconds = seconds % 60; final StringBuilder sb = new StringBuilder(); if (hours != 0) { sb.append(hours).append(" hours "); } if (minutes != 0) { sb.append(minutes).append(" minutes "); } if (seconds != 0) { sb.append(seconds).append(" seconds"); } return sb.toString(); } }