Possible Duplicate:
How to convert a date String to a Date or Calendar object?
How could I do something like this
GregorianCalendar cal = new GregorianCalendar("2012-08-02 12:04:03");
or
Calendar cal = Calendar.getInstance();
cal.setDateTime("2012-08-02 12:04:03");
NOTE: The code snippets above are not actually possible, I would like to mock that behavior.
Further Clarification
Suppose I have a date and time string like "2012-08-02 12:04:03". Is there an efficient way of getting this information into a Calendar object without manually breaking it up into month, year, and day strings then converting them to integers then calling set(Calendar.HOUR) etc?
Currently, I have a form that takes as input the year, month, hour, day, and so on and I pass those individually into a calendar object but it would be nice if I could use a single date and time string like "2012-08-02 12:04:03"