Android Long to Date Convert getActivityTime(long startTime, long endTime)

Here you can find the source of getActivityTime(long startTime, long endTime)

Description

get Activity Time

Declaration

private static String getActivityTime(long startTime, long endTime) 

Method Source Code

//package com.java2s;

public class Main {
    private static String getActivityTime(long startTime, long endTime) {
        long differenceInSeconds = endTime - startTime;

        //Check for seconds
        if (differenceInSeconds < 60) {
            return differenceInSeconds + "sec";
        } else {// w  w w .j  a va2  s  .  c om
            //Check for minutes & hours
            long minutes = differenceInSeconds / 60;
            if (minutes < 60) {
                return minutes + "min";
            } else {
                long hours = minutes / 60;
                minutes = minutes - (hours * 60); // Could be zero.
                return hours + "hr " + (minutes > 0 ? minutes + "min" : "");
            }
        }
    }
}

Related

  1. getDateTimeString(long dateTime)
  2. getLabelForEventInTime(long inTime)
  3. getTimeDelta(long delta, String dateFormat)
  4. timeAgo(long aTime)
  5. isTomorrow(long lTime)
  6. getDate(long timeStamp)
  7. getDateFrom(long timestamp, Context context)
  8. getDateFromLong(long dateLong)
  9. getDateTimeString(long time_milis)