Standard datetime formatting in Android

suggest change

Format a date:

Date date = new Date();
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
String localizedDate = df.format(date)

Format a date and time. Date is in short format, time is in long format:

Date date = new Date();
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG);
String localizedDate = df.format(date)

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents