Java tutorial
//package com.java2s; import android.content.Context; import java.util.Date; public class Main { /** * Return a timestamp * * @param context Application Context */ @SuppressWarnings("UnnecessaryFullyQualifiedName") public static String getTimestamp(Context context) { String timestamp = "unknown"; Date now = new Date(); java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(context); java.text.DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(context); if (dateFormat != null && timeFormat != null) { timestamp = dateFormat.format(now) + ' ' + timeFormat.format(now); } return timestamp; } }