I have this code written to convert a string which i extracted from a webpage into a date format. But whenever I run it, it converts the month into 01.
Can you please help me debug this code?
if (this.subject != null && !this.subject.isEmpty()) {
DateFormat userDateFormat = new SimpleDateFormat("dd-MM-yyyy");
Date df = DATE_FORMAT.parse(this.subject);
Calendar cal = Calendar.getInstance();
cal.setTime(df);
String theDate = String.format("%tY-%tm-%td", cal, cal, cal);
return theDate;
}