I am wondering how to properly display dates in Android. I mean date-formats, which fit to the specific region, where the application is downloaded.
What I am doing atm is:
DateFormat formatter = DateFormat.getDateTimeInstance();
String[] dateParts = date.split(DATE_DELIMITER);
Date temp = new Date(Integer.valueOf(dateParts[4])-1900, Integer.valueOf(dateParts[3]),
Integer.valueOf(dateParts[2]), Integer.valueOf(dateParts[0]),
Integer.valueOf(dateParts[1]));
return formatter.format(temp);
So… There are following problems with this: Java.util.Date is marked as deprecated, and it displays me seconds too, although I don’t want that.
Is there any “Beautiful” solution for that? I’d be glad if you could tell me 🙂
EDIT
To format a date for the current Locale, use one of the static factory methods:
This will format accordingly to the device current locale, that is the one configured in android settings.
More Info
A solution is to use a SimpleDateFormat
Related: Android SimpleDateFormat, how to use it?