transform long value to Date Time - Android java.util

Android examples for java.util:Date Convert

Description

transform long value to Date Time

Demo Code

import android.content.Context;
import android.telephony.TelephonyManager;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main{

    public static String transformDateTime(long t) {
        Date date = new Date(t);
        SimpleDateFormat dateFormat = new SimpleDateFormat(
                "yyyy-MM-dd HH:mm:ss");
        return dateFormat.format(date);
    }//  w  ww  .  ja v a  2s  .  co  m

}

Related Tutorials