I'd like to get the pattern of a "short date" as a String that is customized to the user's locale (e.g. "E dd MMM"). I can easily get a localized DateFormat-object using
DateFormat mDateFormat = android.text.format.DateFormat.getDateFormat(mContext);
but DateFormat doesn't have a .toPattern()-method.
If I use
SimpleDateFormat sdf = new SimpleDateFormat();
String mDateFormatString = sdf.toPattern();
I don't know how to only get the short date pattern String instead of the full M/d/yy h:mm a
I ended up using
String deviceDateFormat = DateFormat.getBestDateTimePattern(Locale.getDefault(), "E dd MMM");
will will give me the "best regional representation" of the supplied input-format, in this case the weekday, day, and month.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With