• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Gregorian Calandar

 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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?
 
Ranch Hand
Posts: 116
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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.
 
Maureen Charlton
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many thanks all - I'll do some further reading in the API
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use deprecated classes or methods, the compiler will give you a warning message.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!