1. Description of false narrative
Exception in thread "main" Java.lang.IllegalArgumentException:Cannot format given Object as a dateat Java.text.DateFormat . Format (Unknown source) at Java.text.Format.format (Unknown source) at Com.you.freemarker.model.FirstDayOfQuarter.getFirstDayOfQuarter (FIRSTDAYOFQUARTER.JAVA:50) at Com.you.freemarker.model.FirstDayOfQuarter.main (firstdayofquarter.java:64)
2. Cause of error
Formatted date SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd"); String firstdayofquarter = Sdf.format (Fisrtdayofmonth.getfisrtdayofmonth (year, month));
While Fisrtdayofmonth.getfisrtdayofmonth (year, month) is of type string, the object in the format () method or the date class
3, the solution of the method
Convert Fisrtdayofmonth.getfisrtdayofmonth (year, month) to date
Copyright notice: This article Bo Master original articles, blogs, without consent, may not be reproduced.
Java gets years on the first day of a quarter of errors