Android Long to Date Convert timeInMillisToText(final long totalTimeInMillis)

Here you can find the source of timeInMillisToText(final long totalTimeInMillis)

Description

time In Millis To Text

Declaration

public static String timeInMillisToText(final long totalTimeInMillis) 

Method Source Code

//package com.java2s;

public class Main {
    public static String timeInMillisToText(final long totalTimeInMillis) {
        final long minutes = (totalTimeInMillis / (1000 * 60)) % 60;
        final long hours = totalTimeInMillis / (1000 * 60 * 60);

        final String hoursWord = getHoursWord(Long.valueOf(hours)
                .intValue());/*from  w w w  . j  a va2  s  .c o  m*/
        final String minutesWord = getMinutessWord(Long.valueOf(minutes)
                .intValue());

        return hours + " " + hoursWord + ", " + minutes + " " + minutesWord;
    }

    private static String getHoursWord(final int hours) {
        String hoursWord;
        if (hours == 1 || hours == 0) {
            hoursWord = "hour";
        } else {
            hoursWord = "hours";
        }
        return hoursWord;
    }

    private static String getMinutessWord(final int minutes) {
        String minutesWord;
        if (minutes == 1 || minutes == 0) {
            minutesWord = "minute";
        } else {
            minutesWord = "minutes";
        }
        return minutesWord;
    }
}

Related

  1. millisToLongDHMS(long duration)
  2. millisToShortDHMS(long duration)
  3. nextDate(long timeMilliSeconds)
  4. parseMills2Time(long elapsedMills)
  5. shortFromUtc(long milliseconds)
  6. timeInMillisecondsToDateStringFull( long timeInMilliseconds)
  7. timestampToDate(long timeStamp)
  8. timestampToDate(long timeStamp)
  9. timestampToISO8601(long aTime)