get Date from long value - Android java.util

Android examples for java.util:Date

Description

get Date from long value

Demo Code


//package com.java2s;
import android.annotation.SuppressLint;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    @SuppressLint("SimpleDateFormat")
    public static String getDate(long timeMillis) {
        return new SimpleDateFormat("yyyy/MM/dd").format(new Date(
                timeMillis));//w ww  .j  a  va  2s. c o m
    }

    public static String getDate(long timeMillis, String strFormat) {
        return new SimpleDateFormat(strFormat).format(new Date(timeMillis));
    }
}

Related Tutorials