Android Localized Date/Time in Android Standard date/time formatting in Android


Example

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)