aspose file tools*
The moose likes Beginning Java and the fly likes  get the year? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark " get the year?" Watch " get the year?" New topic
Author

get the year?

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi All,

Date dt=new Date();
System.err.println("year is"+dt.getYear());


when i execute this program..output :year is108

but i want 2008(insteadof 108)..

please any one can explain me..


thanks & regards,
seetharaman
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

If you look closely at the Date#getYear API, you'll see that this method is deprecated. You'll also find the answer of your question there.


[My Blog]
All roads lead to JavaRanch
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi Christophe Verre,

ok your right.then how can i find the month&years?

please can you explain me?

thanks & regards,
seetharaman
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

thanks verre,
i got the answer like below,

Calendar toDay = Calendar.getInstance();
int year = toDay.get(Calendar.YEAR);

thanks & regards,
seetharaman
Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

Originally posted by seetharam venk:
Hi Christophe Verre,

ok your right.then how can i find the month&years?

please can you explain me?

thanks & regards,
seetharaman



As Christophe suggested you can find in the api that the method is deprecated and which method took it's place. And that's your answer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: get the year?