Java Milliseconds timeMillisToString(long timeMillis)

Here you can find the source of timeMillisToString(long timeMillis)

Description

time Millis To String

License

Apache License

Declaration

public static String timeMillisToString(long timeMillis) 

Method Source Code

//package com.java2s;
/*/*from w  ww  . j  a va  2s . c  om*/
 * codjo.net
 *
 * Common Apache License 2.0
 */

public class Main {
    public static String timeMillisToString(long timeMillis) {
        StringBuilder strTime = new StringBuilder();
        long jour = (int) (timeMillis / 86400000);
        long heure = (int) ((timeMillis - jour * 86400000) / 3600000);
        long minute = (int) ((timeMillis - jour * 86400000 - heure * 3600000) / 60000);
        long seconde = (int) ((timeMillis - jour * 86400000 - heure * 3600000 - minute * 60000) / 1000);
        long milliseconde = (int) (timeMillis - jour * 86400000 - heure * 3600000 - minute * 60000
                - seconde * 1000);

        if (jour > 0) {
            strTime.append(jour).append("j ");
        }
        if (heure > 0) {
            strTime.append(heure).append("h ");
        }
        if (minute > 0) {
            strTime.append(minute).append("mn ");
        }
        if (seconde > 0) {
            strTime.append(seconde).append("s ");
        }
        if (jour + heure + minute + seconde == 0) {
            strTime.append(milliseconde).append("ms");
        }
        return strTime.toString().trim();
    }
}

Related

  1. ticksWithMillisecondsSetTo(long ticks, int milliseconds)
  2. tilNextMillis(long lastTimestamp)
  3. timeAfterMillis(final long millis)
  4. timeIncMillisToTimeControl(long startTimeMillis, long startIncMillis)
  5. timeMillisToDate(Long timeMillis)
  6. timeoutPropertyToIntMillis(long value)
  7. timeSince_MILLIS(long start_PMILLIS)
  8. timeSinceMillis(long prevTime)
  9. timeSinceMillis(long timestart)