Reputation: 470
I have two elements in my string and I would like to take the second element and put in a new string.
String data;
The data string contains:
27 Nov 2012
30 Oct 2012
The two dates are separated by \n
.
Any help is appreciated :)
Upvotes: 1
Views: 114
Reputation: 33370
Another way to do it:
String dates[] = data.split("\n");
String second = dates[1];
Upvotes: 4
Reputation: 1647
String first = data.substring(0, data.indexOf("\n"));
String second = data.substring(data.indexOf("\n"));
Hope that helps!
Upvotes: 4