Getting wrong month when using SimpleDateFormat.parse

Use:

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

Use MM for month, mm for minutes as stated by documentation

If you want to print a Date in a specific format, you should use:

 sdf.format(birthday)

or another SimpleDateFormat if you want to pring it in a different format…

Leave a Comment