When use “EEEE, MMM dd, yyyy” you hard fixing the order of month name and date: month, then day.
But for many countries it is not true! Many locales supposed to use format “21 Mar 2018” not “Mar 21, 2018”
Also, user can change 12/24 time format independently of system language. For example, I can use English (United States) language for UI, but set 24 time format in Time&Date settings.
The Locale class contains various static locales that can be passed in such as Locale.US or Locale.UK and it will adjust your pattern accordingly. Here’s how I implemented it:
I just changed the GETTER in Crime.java to return the converted string, and in the BIND method I removed the .toString() call.
In my view this is the best location for the date conversion, what do you think?
/**
* THIS GETTER HAS BEEN MODIFIED FOR THE CHALLENGE P 204, BY MAKING
THE DATA CONVERSION
* AND RETURNING THE STRING TO CRIME LIST FRAGMENT.JAVA
*/
public String getDate() {
String mDateView = DateFormat.getDateInstance(DateFormat.FULL).format(mDate);
return mDateView;
}
public void bind(Crime crime) {
mCrime = crime;
mTitleTextView.setText(mCrime.getTitle());
mDateTextView.setText(mCrime.getDate());//CHALLENGE DATA from CRIME.JAVA
mSolvedImageView.setVisibility(crime.isSolved() ? View.VISIBLE : View.GONE);
}//method