Convert date from yyyy-mm-dd to utc format

1.5k views Asked by At

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?

1

There are 1 answers

0
Ihar Sadounikau On BEST ANSWER

Use yyyy-MM-dd insted yyyy-mm-dd because 'm' in lowercase is minutes. Documentation : link