I need to omit the year in the localized date. The localized DateFormat containing the year can be obtained by DateFormat.getDateInstance()
I cannot use SimpleDateFormat
directly as I will have to assume the relative orderings. I was wondering if there is a way to determine the localized orderings of the parts, or get the format string itself, so that I can remove the y's
from it and construct a SimpleDateFormat.
CodePudding user response:
Use FORMAT_SHOW_DATE
or FORMAT_NO_YEAR
to remove year from a date regardless of its locale:
int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR;
String monthAndDayWithoutYear = DateUtils.formatDateTime(context, millisecs, flags);