How to get number of days between two calendar instance?

后端 未结 11 1104
孤城傲影
孤城傲影 2020-12-05 01:58

I want to find the difference between two Calendar objects in number of days if there is date change like If clock ticked from 23:59-0:00 there should be a day

11条回答
  •  爱一瞬间的悲伤
    2020-12-05 02:33

    Calendar day1 = Calendar.getInstance();

    Calendar day2 = Calendar.getInstance();

    int diff = day1.get(Calendar.DAY_OF_YEAR) - day2.get(Calendar.DAY_OF_YEAR);

提交回复
热议问题