Java Time Readable Format toTimeExpression(long ms, int frames)

Here you can find the source of toTimeExpression(long ms, int frames)

Description

to Time Expression

License

Apache License

Declaration

public static String toTimeExpression(long ms, int frames) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String toTimeExpression(long ms) {
        return toTimeExpression(ms, -1);
    }//from   www . ja va  2 s.c o m

    public static String toTimeExpression(long ms, int frames) {
        String minus = ms >= 0 ? "" : "-";
        ms = Math.abs(ms);

        long hours = ms / 1000 / 60 / 60;
        ms -= hours * 1000 * 60 * 60;

        long minutes = ms / 1000 / 60;
        ms -= minutes * 1000 * 60;

        long seconds = ms / 1000;
        ms -= seconds * 1000;
        if (frames >= 0) {
            return String.format("%s%02d:%02d:%02d:%d", minus, hours, minutes, seconds, frames);
        } else {
            return String.format("%s%02d:%02d:%02d.%03d", minus, hours, minutes, seconds, ms);
        }
    }
}

Related

  1. toTime(int duration)
  2. toTime(long ms)
  3. toTime(long nanos)
  4. toTime(long time)
  5. toTime2(int value, int nanos, int meta)
  6. toTimeFormat(String _srcTime)
  7. toTimeHumanReadable(final long time)
  8. toTimeSpanDescription(long time)
  9. toTimestamp(long time)