Java得到年在一个季度的错误的第一天
1、错误叙述性说明
Exception in thread "main" java.lang.IllegalArgumentException: Cannot format given Object as a Date at 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、错误原因
//格式化日期 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String firstDayOfQuarter = sdf.format(FisrtDayOfMonth.getFisrtDayOfMonth(year, month));
而FisrtDayOfMonth.getFisrtDayOfMonth(year, month)是String类型的,format()方法内的事对象或者是Date类
3、解决的方法
将FisrtDayOfMonth.getFisrtDayOfMonth(year, month)转换成Date
版权声明:本文博主原创文章,博客,未经同意,不得转载。