I have a string stored in a database (example: Sat Jul 09 14:20:31 EDT 2011
)
This is stored as string (I am aware of SQLs date capabilities, but I'm not exploring that at this point).
I want to pull this strong and compare it with the current time using the Date.compare
function
Date currentDate = new Date(); // the new current time value
mCursor.getString(mCursor.getColumnIndex(TIMECOLUMN)
//the old stored time value, pulled from the SQL database
From the database I have a string value already formatted as a proper date. But I don't have an obvious function to compare this to my current date as a date object.
I need to know if one is greater than, less than, or equal to, the other. The Date compare
function will allow this, but the object needs to be a date object.
I have tried SimpleDateFormat
seeded with the string's date format, but I get a parse exception "unparsable date", perhaps because it is already formatted?
Date currentDate = new Date();
SimpleDateFormat dateTest = new SimpleDateFormat("E M d HH:mm:ss z y");
if(currentDate.compareTo(dateTest.parse((mCursor.getString(mCursor.getColumnIndex(TIMECOLUMN))))) > 0)
returns java.text.ParseException: Unparseable date: Sat Jul 09 14:20:31 EDT 2011
I suspect my SimpleDateFormat seed is incorrect. Insight Appreciated