utc Time To Date - Android java.util

Android examples for java.util:Time

Description

utc Time To Date

Demo Code


//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static Date utcTimeToDate(long utcTime) {
        Date resultDate = null;/*from  ww  w . j  a  va 2 s  .  co  m*/
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(secondTurnMs(utcTime));
        resultDate = calendar.getTime();
        return resultDate;
    }

    public static long secondTurnMs(long utcTime) {
        if (String.valueOf(utcTime).length() == 10) {
            utcTime *= 1000;
        }
        return utcTime;
    }
}

Related Tutorials