Getting difference between two dates Android

后端 未结 6 1807
故里飘歌
故里飘歌 2020-12-01 22:05

Am having string posting date like :

2011-03-27T09:39:01.607

and There is current date .

I want to get difference between these tw

6条回答
  •  鱼传尺愫
    2020-12-01 22:52

    You can find difference between two dates without using any library

    You just need to find out difference between dates like this :

        long diff = currentdate.getTime() - temp_date.getTime();
                        //current date            //other date
    

    by this you will get difference in milliseconds .. Now you can format this according to your need i.e in hours ago or months ago or years ago format,just by using if conditions

    See complete example HERE..

    Hope it helps..!

提交回复
热议问题