String selectedDate = \"2012-\" + createdMonth + \"-\" + createdDay; SimpleDateFormat dateFormat = new SimpleDateFormat(\"yyyy-MM-dd\"); try { createdDate = dateFo
You need to print as below. Point is that you need to use the formatter object you have created while printing as well.
System.out.println(dateFormat.format(createdDate));