Does anybody know how to get the format string used by the system when formatting a date using
DateFormat.getLongDateFormat(Context context).format(Date date)
SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. It allows for formatting (date → text), parsing (text → date), and normalization. SimpleDateFormat allows you to start by choosing any user-defined patterns for date-time formatting.
getInstance(). getTime(); System. out. println("Current time => " + c); SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy"); String formattedDate = df.
To get the date format pattern you can do:
Format dateFormat = android.text.format.DateFormat.getDateFormat(getApplicationContext()); String pattern = ((SimpleDateFormat) dateFormat).toLocalizedPattern();
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