Android Calendar illegalArgumentException when calendar.month set to 1
问题 The code below works fine except when calendar.MONTH set to 1 (Feb) ,and I do not know why ? Thanks. Calendar calendar = Calendar.getInstance(); calendar.setLenient(false); calendar.set(Calendar.YEAR, 2013); calendar.set(Calendar.MONTH, 1); // Only when "Feb" failed with illegalArgumentException int maxDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); <= If Calendar.MONTH set to 1, this line will "java.lang.IllegalArgumentException" 回答1: You're getting the current date in getInstance.