Java gets years on the first day of a quarter of errors

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.