wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes java.util.Date getYear() method is deprecated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java.util.Date getYear() method is deprecated" Watch "java.util.Date getYear() method is deprecated" New topic
Author

java.util.Date getYear() method is deprecated

albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 245
java.util.Date getYear() method is deprecated, what is the best way to get the year value using JDK6 libraries (not third party open source Java libraries)?

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

By using java.util.Calendar. Create an instance, set its time to the Date object, then get the year.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 245
Rob Spoor wrote:By using java.util.Calendar. Create an instance, set its time to the Date object, then get the year.

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Exactly like that
 
 
subject: java.util.Date getYear() method is deprecated
 
Similar Threads
a problem with Date class
compiles with warning?
Garbage Collection
Alternative to deprecated Date.toGMTString()
get the year?