Java Long Number to Time convertTime(Long time)

Here you can find the source of convertTime(Long time)

Description

convert Time

License

Apache License

Declaration

public static String convertTime(Long time) 

Method Source Code

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

public class Main {
    public static final String TIME_FORMAT = "00:00:00";

    public static String convertTime(Long time) {
        long timelong = time.longValue();
        if (timelong == 0) {
            return TIME_FORMAT;
        }//  www. j a  v a  2  s. c o m
        if (timelong > 0) {
            long h = 0, hh = 0;
            long m = 0, mm = 0;
            long s = 0;
            h = timelong / 3600;
            hh = timelong % 3600;
            m = hh / 60;
            mm = hh % 60;
            s = mm;
            String hStr, mStr, sStr = "";
            if (h < 10) {
                hStr = "0" + h;
            } else {
                hStr = "" + h;
            }
            if (m < 10) {
                mStr = "0" + m;
            } else {
                mStr = "" + m;
            }
            if (s < 10) {
                sStr = "0" + s;
            } else {
                sStr = "" + s;
            }
            // if (h > 0) {
            // return hStr + ":" + mStr + ":" + sStr;
            // }
            // if (h == 0 && m > 0) {
            // return mStr + ":" + s;
            // }
            // if (m == 0 && s > 0) {
            // return s + "s";
            // }
            return hStr + ":" + mStr + ":" + sStr;
        }
        return TIME_FORMAT;
    }
}

Related

  1. convertLongToTimestampString(String dateFormat, Long millSec)
  2. ConvertLongToTimeString(long lastModified)
  3. convertMillisToHHMMSS(long millis)
  4. convertMillsToDateString(long currentTimeMillis)
  5. convertTime(long difference)
  6. convertTime(long time)
  7. convertTime(long time)
  8. convertTime(long time)
  9. convertTime(long time)