Android/Java - Date Difference in days

前端 未结 18 1179
感动是毒
感动是毒 2020-11-22 14:17

I am getting the current date (in format 12/31/1999 i.e. mm/dd/yyyy) as using the below code:

Textview txtViewData;
txtViewDate.setText(\"Today is \" +
              


        
18条回答
  •  轮回少年
    2020-11-22 14:45

    Use jodatime API

    Days.daysBetween(start.toDateMidnight() , end.toDateMidnight() ).getDays() 
    

    where 'start' and 'end' are your DateTime objects. To parse your date Strings into DateTime objects use the parseDateTime method

    There is also an android specific JodaTime library.

提交回复
热议问题