In the above code please note the first line after the try block. This uses the Date class of which I understand is depicted. Does anyone know whether or not there is a similiar method in the Gregorian Calander?
"In the above code please note the first line after the try block."
Do you mean this line:
Date formattedDate = sdf.parse(inputDate);
"This uses the Date class of which I understand is depicted."
"Depicted"? Do you mean "deprecated"? No, there's nothing that's deprecated in that line. Does the compiler tell you that you're using a deprecated method? Can you please copy and paste the exact error message here?
So you are looking for a parse method in a (Gregorian)Calendar? Anyway ... the answer is sorta' because a DateFormat derived class has an associated Calendar that tells it how to interpret milliseconds (i.e. Date) into Calendar fields, which DateFormat can then turn into Strings. The (usually default) Locale gets mixed in there too so the language is correct. So the (Gregorian)Calendar is already involved in the parse. See DateFormat.getCalendar() and DateFormat.setCalendar().
Of course, you can also do a Calendar.getTime() to go the other direction.
Hope this helps.
posted 12 years ago
Jasper Thank you for your response.
I have no error message. My understanding is the Date class has been deprecated and replaced using the Gregorian Calandar so I'm attempting to get an understanding.
Are you implying that the SimpleDateFormat can be used for the Gregorian Calander?
Therefore I would use Calendar c = Calendar.getInstance(); c.set(sdf);