Format Date Time in long type as yyyy-MM-dd HH:mm:ss format - Android java.util

Android examples for java.util:Date Format

Description

Format Date Time in long type as yyyy-MM-dd HH:mm:ss format

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  va2 s . c o m

}

Related Tutorials