I have two String date 8-11-2011 and 8-12-2011 . I want to compute days between two string . How can I do that ? I don't want to use Joda API . Please explain with example .
Asked
Active
Viewed 331 times
2 Answers
0
please refer to this for the problem solution

Community
- 1
- 1

Swapnil Kadam
- 4,075
- 5
- 29
- 35
-
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Lundin May 30 '13 at 07:32
-
ok. :) but may i know if stackoverflow linked pages may ever become invalid? – Swapnil Kadam May 30 '13 at 09:16
-
Mark this Question as a duplicate rather than link to an Answer. – Basil Bourque Jan 30 '18 at 22:58
0
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..

ngesh
- 13,398
- 4
- 44
- 60
-
We have the [*java.time*](https://docs.oracle.com/javase/9/docs/api/java/time/package-summary.html) classes now, so need to bother with this kind of roll-your-own approach. For early Android, see [*How to use ThreeTenABP…*](http://stackoverflow.com/q/38922754/642706). – Basil Bourque Jan 30 '18 at 22:57