Android Long to Date Convert hrColMin(final long time, final boolean alwaysIncludeHours)

Here you can find the source of hrColMin(final long time, final boolean alwaysIncludeHours)

Description

hr Col Min

Declaration

public static StringBuilder hrColMin(final long time,
            final boolean alwaysIncludeHours) 

Method Source Code

//package com.java2s;

import android.util.Log;

public class Main {
    public static StringBuilder hrColMin(final long time,
            final boolean alwaysIncludeHours) {
        final long seconds = time / 1000;
        final long minutes = (seconds / 60) % 60;
        final long hours = (seconds / (60 * 60)) % 60;
        Log.i("DateTimeUtils", "hrColMin  hours  minutes  seconds: "
                + hours + "  : " + minutes + "  : " + seconds);
        final StringBuilder asText = new StringBuilder();
        if (alwaysIncludeHours || hours > 0) {
            if (hours < 10) {
                asText.append(0);/*from w ww.  j  av  a  2 s  .c  o  m*/
            }
            asText.append(hours);
            asText.append(":");
        }
        if (minutes > 0) {
            if (minutes < 10) {
                asText.append(0);
            }
            asText.append(minutes);
        } else {
            asText.append("00");
        }
        return asText;
    }
}

Related

  1. getUTCandRelativeDateFromElapsedTime( long elapsedTime)
  2. getUniversalDateStamp(long time)
  3. getUpdateDateStr(long time)
  4. getUpdateTimeStr(long time)
  5. getYear(long dateTimeMillis)
  6. hrColMinColSec(final long time, final boolean alwaysIncludeHours)
  7. isAtMostNMonthsAgo(long date, int howMany)
  8. isAtMostNWeeksAgo(long date, int howMany)
  9. isYesterday(long date)