I have a string like
8/29/2011 11:16:12 AM. I want to split that string into separate variables like
date = 8/29/2011
time = 11:16:12 AM
Is this possible? If so, how would I do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
(Edit: See Answer by Ole V.V. below for a more modern (Java 8) approach for the first version)
One way to do is parse it to a date object and reformat it again:
If you just want to slice it into date-time pieces, just use split to get pieces
or