开发者

Date Difference in Android [duplicate]

This question already has answers here: Android/Java - Date Difference in days (18 answers) Closed 5 years ago.

I have two String date 8-11-2011 and 8-12-2011 . I want to compute days between tw开发者_Go百科o string . How can I do that ? I don't want to use Joda API . Please explain with example .


I don't know if you have any direct api for this but you can do this,

String s1 = "8-11-2011";
String s2 = "8-12-2011";

String[] arr1 = s1.split("-");
String[] arr2 = s2.split("-");
for(int i = 0; i<arr1.length; i++){
Integer diff = Integer.valuof(arr1[i])-Integer.valueOf(arr2[i])// its just an idea. you may need if conditions here
}

and its not reliable..


please refer to this for the problem solution

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜