Android examples for java.util:Date Format
Returns the date and time in a simple format. This is non-localized
import android.content.Context; import android.text.format.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main{ /**//w w w . j a v a 2 s .c o m * Returns the date and time in a simple format. This is non-localized * @param date * @param context * @return */ public static String getSimpleDateTime(Date date, Context context) { java.text.DateFormat df = DateFormat.getDateFormat(context); java.text.DateFormat tf = DateFormat.getTimeFormat(context); Date modTime = new Date(date.getTime()); String strModTime = shortDateFormat.format(modTime); strModTime = strModTime.substring(0, 2) + "/" + strModTime.substring(3); return df.format(modTime) + " " + tf.format(modTime); } }