Adding Days to Calendar

后端 未结 4 1418
独厮守ぢ
独厮守ぢ 2021-01-05 07:08

I\'m new to this site and I have just started learning Java. I\'m trying to add couple days to the GregorianCalendar but it doesn\'t work. Here... (Ignore the top chunk), it

4条回答
  •  情深已故
    2021-01-05 07:22

    You need to change the lines that look like:

    setup.add(day, -1);
    setup.add(day, -10);
    

    to

    setup.add(GregorianCalendar.DAY_OF_MONTH, -1);
    setup.add(GregorianCalendar.DAY_OF_MONTH, -10);
    

    See GregorianCalendar for more information.

提交回复
热议问题