Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1001
  • Last Modified:

java.util.Date deprecated methods

java.util.Date object methods are mostly deprecated.
let say i want to get year of a date object, how to do it, without using deprecated method getYear()?
0
kokshong
Asked:
kokshong
1 Solution
 
f_98Commented:
http://java.sun.com/j2se/1.4.1/docs/api/java/util/Calendar.html

use the calendar object, something like;


Date myDate = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(myDate);
int year = cal.get(Calendar.YEAR);


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now