🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.api
3 messages
3 total messages Started by News Fri, 01 Nov 2002 14:25
getting a current year
#802
Author: News
Date: Fri, 01 Nov 2002 14:25
3 lines
1180 bytes
Please, I need current year. If I use Date.getYear(), JBuilder  write '
getYear is deprecated. Seek for better solution' .  If run my application, I
get a wrong year. Please, can you help me?
Re: getting a current year
#803
Author: Gillmer J. Derge [TeamB]
Date: Fri, 01 Nov 2002 16:43
17 lines
1573 bytes
"News" <silva@carlosilva.com> wrote in message
news:3dc29cfa@newsgroups.borland.com...
> Please, I need current year. If I use Date.getYear(), JBuilder  write '
> getYear is deprecated. Seek for better solution' .

Well, did you seek for a better solution?  The API documentation for the
getYear method tells you what to use as an alternative: "As of JDK version
1.1, replaced by Calendar.get(Calendar.YEAR) - 1900."

Something like this (untested) should work.

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date());
    int year = Calendar.get(Calendar.YEAR) - 1900;

--
Gillmer J. Derge [TeamB]
Re: getting a current year
#766
Author: Scott Ding
Date: Thu, 09 Jan 2003 12:40
14 lines
1479 bytes
"News" <silva@carlosilva.com> д����Ϣ����
:3dc29cfa@newsgroups.borland.com...
> Please, I need current year. If I use Date.getYear(), JBuilder  write '
> getYear is deprecated. Seek for better solution' .  If run my application,
I
> get a wrong year. Please, can you help me?
>
>
If you only want to get current year
you can try this.
     Calendar calendar = Calendar.getInstance();
     calendar.setTime(new Date());
     int year = calendar.get(Calendar.YEAR) ;
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads