Android examples for java.util:Date Format
Gets a formatted String representing the given exif DateTime according to the context's MediumDateFormat and TimeFormat
import android.content.Context; import android.util.Log; import android.util.Log; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main{ /**/*from w w w . j av a2 s.c om*/ * Gets a formatted String representing the given exifDateTime according to the context's * MediumDateFormat and TimeFormat * @param context * @param exifDateTime * @return */ public static String formatExifDateTime(Context context, String exifDateTime) { if (exifDateTime == null) return null; try { DateFormat df = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss"); Date date = df.parse(exifDateTime); Calendar calendar = GregorianCalendar.getInstance(); calendar.setTime(date); return android.text.format.DateFormat.getMediumDateFormat( context).format(date) + " at " + android.text.format.DateFormat.getTimeFormat(context) .format(date); //return date.toString(); } catch (ParseException pe) { Log.e(TAG, "formatExifDateTime: ", pe); return null; } } }