How to format correctly according to the device configuration date and time when having a year, month, day, hour and minute?
In my opinion, android.text.format.DateFormat.getDateFormat(context)
makes me confused because this method returns java.text.DateFormat
rather than android.text.format.DateFormat
- -".
So, I use the fragment code as below to get the current date/time in my format.
android.text.format.DateFormat df = new android.text.format.DateFormat();
df.format("yyyy-MM-dd hh:mm:ss a", new java.util.Date());
or
android.text.format.DateFormat.format("yyyy-MM-dd hh:mm:ss a", new java.util.Date());
In addition, you can use others formats. Follow DateFormat.