Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Date to calendar

843789May 24 2010 — edited May 27 2010
I have a class TestDate which extends Date . It has an constructor with 3 parameters


public TestDate(int year, int month, int day)
{
super(year, month, day);

}

public static TestDate getCurrentDate()
{
GregorianCalendar cal = new GregorianCalendar();

return new TestDate(cal.get(Calendar.YEAR)-1900,cal.get(Calendar.MONTH),cal.get(Calendar.DAY_OF_MONTH));*/

}





(Few methods of Date class in java 1.6 are deprecated so I m using calendar class.)

I have a user defined method which calls the constructor, and gets the current date by calling the constructor but
super(year, month, day) for Date is deprecated. Please can you suggest me the replacement for the constructor using calendar class.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 24 2010
Added on May 24 2010
9 comments
222 views