Android examples for java.util:Date Timestamp
Return a timestamp
import java.util.Date; import android.content.Context; public class Main { /**// ww w . ja va 2 s . com * Return a timestamp * * @param context * Application Context */ public static String getTimestamp(final Context context) { String timestamp; 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; } }