What you're basically trying to do is this:-
Calendar cal = Calendar.getInstance();
Date date = cal.getTime();
The reason being, the String
which you're printing is just a String
representation of the Date
in your required format. If you try to convert it to date, you'll eventually end up doing what I've mentioned above.
Formatting Date
(cal.getTime()) to a String
and trying to get back a Date
from it - makes no sense. Date
has no format as such. You can only get a String
representation of that using the SDF.