aspose file tools*
The moose likes Beginning Java and the fly likes Gregorian Calandar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Gregorian Calandar" Watch "Gregorian Calandar" New topic
Author

Gregorian Calandar

Maureen Charlton
Ranch Hand

Joined: Oct 04, 2004
Posts: 218


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?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14269
    
  21

"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?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Chris Beckey
Ranch Hand

Joined: Jun 09, 2006
Posts: 116

Do you mean the line:

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.
Maureen Charlton
Ranch Hand

Joined: Oct 04, 2004
Posts: 218
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);
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


My understanding is the Date class has been deprecated and replaced using the Gregorian Calandar so I'm attempting to get an understanding.

Your understanding is not quite right. java.util.Date is not deprecated, however the vast bulk of its methods have been. If you look at the JavaDocs you'll see which methods.


Are you implying that the SimpleDateFormat can be used for the Gregorian Calander?

Yes you can parse a String representation of your Date with SimpleDateFormat.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Maureen Charlton
Ranch Hand

Joined: Oct 04, 2004
Posts: 218
Many thanks all - I'll do some further reading in the API
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14269
    
  21

If you use deprecated classes or methods, the compiler will give you a warning message.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Gregorian Calandar