Android Long to Date Convert getUTCTimeFromLocalMillis(long localMillis)

Here you can find the source of getUTCTimeFromLocalMillis(long localMillis)

Description

Convert a local timestamp into UTC time

Parameter

Parameter Description
localTimeMillis a parameter

Declaration

static long getUTCTimeFromLocalMillis(long localMillis) 

Method Source Code

//package com.java2s;
import java.util.Calendar;

public class Main {
    /**//w  ww.j  av a  2s. c om
     * Convert a local timestamp into UTC time
     * 
     * @param localTimeMillis
     * @return
     */
    static long getUTCTimeFromLocalMillis(long localMillis) {
        return localMillis + getTimeZoneOffsetInMillis();
    }

    /**
     * @return the timezone offset of the current device relative to UTC
     */
    static long getTimeZoneOffsetInMillis() {
        Calendar cal = Calendar.getInstance();
        return cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET);
    }
}

Related

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