I have a date, "2015-06-08". I want convert it to "08 June 2015"
String oldDateString = "2015-06-08";
SimpleDateFormat oldDateFormat = new SimpleDateFormat("yyyy-mm-dd", Locale.getDefault());
SimpleDateFormat newDateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.getDefault());
Date date = oldDateFormat.parse(oldDateString);
String result = newDateFormat.format(date);
but this does not work correctly. It returns "08 January 2015". What have I done wrong?
Use
yyyy-MM-dd
instedyyyy-mm-dd
because 'm' in lowercase is minutes. Documentation : link