Android Long to Date Convert formatSecondsToHHMM(long seconds)

Here you can find the source of formatSecondsToHHMM(long seconds)

Description

Converts seconds into hours and minutes.

Parameter

Parameter Description
seconds - time in seconds

Return

String - in the form of h min

Declaration

public static String formatSecondsToHHMM(long seconds) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*w w w  .  j  av a  2 s.co  m*/
     * Converts seconds into hours and minutes. 
     * 
     * @param seconds - time in seconds 
     * @return String - in the form of <hours>h <minutes>min
     */
    public static String formatSecondsToHHMM(long seconds) {
        long m = (seconds / 60) % 60;
        long h = (seconds / 60) / 60;
        String hhmm = "";

        if (h > 0) {
            hhmm += h + "h";
        }
        if (m > 0) {
            hhmm += " ";
            hhmm += m + "min";
        }
        if (hhmm.length() < 1) {
            hhmm += "1min";
        }
        return hhmm;
    }
}

Related

  1. transformDateTime(long t)
  2. millis2cal(long milliseconds, boolean clearTime)
  3. millisToString(long l)
  4. stdDateFormat(long t)
  5. formatElapsedTime(long totalTimeSeconds)
  6. getStringByFormat(long milliseconds, String format)
  7. getStringByFormat(long milliseconds, String format)
  8. convertToTime(long time)
  9. formatDateTime(long timeToFormatInMilliseconds)