Android examples for java.util:Time
get Time String
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import android.annotation.SuppressLint; public class Main { public static final String COMMON_FORMAT = "yyyy.MM.dd HH:mm:ss"; @SuppressLint("NewApi") public static String getTimeString(String strFormat) { if (strFormat.isEmpty()) { strFormat = COMMON_FORMAT;/*from w w w . jav a2s .c o m*/ } SimpleDateFormat sd = new SimpleDateFormat(strFormat); String str = sd.format(new Date()); return str; } }