Here you can find the source of getReadableMillisTime(long millis)
public static String getReadableMillisTime(long millis)
//package com.java2s; /*/*from w w w . j ava2 s . com*/ * Copyright (c) 2014. NoxPVP.com * * All rights are reserved. * * You are not permitted to * Modify * Redistribute nor distribute * Sublicense * * You are required to keep this license header intact * * You are allowed to use this for non commercial purpose only. This does not allow any ad.fly type links. * * When using this you are required to * Display a visible link to noxpvp.com * For crediting purpose. * * For more information please refer to the license.md file in the root directory of repo. * * To use this software with any different license terms you must get prior explicit written permission from the copyright holders. */ public class Main { public static String getReadableMillisTime(long millis) { int ms = (int) (millis % 1000); millis /= 1000; int seconds = (int) (millis % 60); millis /= 60; int minutes = (int) (millis % 60); millis /= 60; int hours = (int) (millis % 24); millis /= 24; int days = (int) (millis % Integer.MAX_VALUE); StringBuilder sb = new StringBuilder(); if (days != 0) sb.append(days).append("D "); if (hours != 0) sb.append(hours).append("H "); if (minutes != 0) sb.append(minutes).append("M "); if (seconds != 0) sb.append(seconds).append("S "); if (ms != 0) sb.append(ms).append("MS "); return sb.toString(); } }