I have the following code. The problem occurs when getting the month. It says 'The 'month' argument must be in the range 1 to 12.' and it always return 0. Why?
String target = "2013-01-04";
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date date = df.parse(target);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int year = cal.get(Calendar.YEAR);
System.out.println("year-"+year);
int month = cal.get(Calendar.MONTH);
System.out.println("month-"+month);
int day = cal.get(Calendar.DAY_OF_MONTH);
System.out.println("day-"+day);