I have a date and time 2011-02-28 07:00:52 as a string. How can I read it and then parse it as a date and time to compare it to an Android system time and date?
2 Answers
String time; // your string representing the time
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyyMMddHHmmss");
Date startDate = dateFormatter.parse(time);
and
new Date()
will give you a date representing the current date and time.
1 Comment
Thunder Rabbit
In my case, I had to put hyphens, a space, and colons in the parameter: ... = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");