Android Long to Date Convert getUTCandRelativeDateFromElapsedTime( long elapsedTime)

Here you can find the source of getUTCandRelativeDateFromElapsedTime( long elapsedTime)

Description

get UT Cand Relative Date From Elapsed Time

License

Open Source License

Declaration

public static String getUTCandRelativeDateFromElapsedTime(
            long elapsedTime) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Date;
import android.os.SystemClock;

public class Main {
    public static String getUTCandRelativeDateFromElapsedTime(
            long elapsedTime) {
        try {/* w  w  w. j av a 2  s.  c  o m*/
            SimpleDateFormat formatter = new SimpleDateFormat("dd/HH:mm:ss");
            int flags = android.text.format.DateUtils.FORMAT_ABBREV_RELATIVE;
            long curTime = System.currentTimeMillis();
            long time = curTime
                    - (SystemClock.elapsedRealtime() - elapsedTime);
            StringBuffer sb = new StringBuffer();
            sb.append(formatter.format(new Date(time)));
            if (time <= curTime) {
                sb.append('{');
                sb.append(android.text.format.DateUtils
                        .getRelativeTimeSpanString(
                                time,
                                curTime,
                                android.text.format.DateUtils.MINUTE_IN_MILLIS,
                                flags).toString());
                sb.append('}');
            }
            return sb.toString();
        } catch (java.lang.Throwable th) {
            return "TIME_ERROR";
        }
    }
}

Related

  1. getTimeLabel(long date)
  2. getTimeLabel(long time)
  3. getTimestampDatetime(long milliseconds)
  4. getUTCTimeFromElapsedTime(long elapsedTime)
  5. getUTCTimeFromLocalMillis(long localMillis)
  6. getUTCandRelativeDateFromElapsedTime( long elapsedTime)
  7. getUniversalDateStamp(long time)
  8. getUpdateDateStr(long time)
  9. getUpdateTimeStr(long time)