开发者

Date Difference in Android [duplicate]

开发者 https://www.devze.com 2023-04-03 23:30 出处:网络
This question already has answers here: Android/Java - Date Difference in days (18 answers) Closed 5 years ago.
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

精彩评论

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

关注公众号