Any idea what is happening to this code that the dates do not coincide? First prints "20 December 2017" and then "Date with new format:2017-01-01"...
SimpleDateFormat formatter = new SimpleDateFormat("d MMMM YYYY");
SimpleDateFormat formatterNew = new SimpleDateFormat("yyyy-MM-dd");
try{
System.out.println(formatter.format(new Date()));
Date date = formatter.parse("20 December 2017");
System.out.println("Date with new format:" +formatterNew.format(date));
}catch(Exception ex){
ex.printStackTrace();
}