Android examples for java.util:Date Format
Format Date Time in long type as yyyy-MM-dd HH:mm:ss format
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 }