I Get the following Date from my SQLite database which get pulled down as a string in the following format '03-07-2015'.
I want this format to display like this 'Fri 3rd July 2015' I am doing this using SimpleDateFormat, I then need to pass this into an ArrayList, I cannot quite get this to work, any advice to what I am doing wrong would be much appreciated.
String dayNumberSuffix = getDayOfMonthSuffix(3);
SimpleDateFormat sdf = new SimpleDateFormat("EEEE dd'" + dayNumberSuffix + "' MMMM yyyy");
String d = sdf.format(cursor.getString(1));
dates.add(d); // ArrayList<String>
String getDayOfMonthSuffix(final int n) {
switch (n % 10) {
case 1: return "st";
case 2: return "nd";
case 3: return "rd";
default: return "th";
}
}
I have tried a few different variations, but I believe the one above is closest.