I have a string like 8/29/2011 11:16:12 AM. I want to split that string into separate variables like
8/29/2011 11:16:12 AM
date = 8/29/2011 time = 11:16:12 AM
You can do it by splitting your string into two substrings, as follows
String main = "8/29/2011 11:16:12 AM"; String s[] = main.split(" ",2); String date = s[0]; String time = s[1];
NOTE: The split method will split the string into two parts as mentioned in the second argument.