Java Calendar date error

前端 未结 5 1886
栀梦
栀梦 2021-01-26 02:41

Can anyone please help me understand why I am getting different month values for

SimpleDateFormat dateFormat = new SimpleDateFormat(\"dd/MM/yyyy\");    
Syst         


        
5条回答
  •  滥情空心
    2021-01-26 03:07

    In Calendar class, MONTH start from index 0. So, January is 0, February is 1, and hence September is 8.

    P.S.: - That's true that this is an Inconsistency in Calendar class, so I would suggest you to take a look at Joda-Time API to make your life easier while working with date-time data.

提交回复
热议问题