Android Localized Date/Time in Android Custom localized date format with DateUtils.formatDateTime()


Example

DateUtils.formatDateTime() allows you to supply a time, and based on the flags you provide, it creates a localized datetime string. The flags allow you to specify whether to include specific elements (like the weekday).

Date date = new Date();
String localizedDate = DateUtils.formatDateTime(context, date.getTime(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY);

formatDateTime() automatically takes care about proper date formats.