Article View: borland.public.jbuilder.java.language
Article #17193Re: Get current date
From: Franck Rasolo
Date: Thu, 10 Dec 1998 00:00
Date: Thu, 10 Dec 1998 00:00
47 lines
1873 bytes
1873 bytes
Michael,
It's actully as straightforward as this :-
// Rather than creating an object GregorianCalendar which
// won't be used afterwards, call Calendar's static method
// Calendar.getInstance()
Date date = Calendar.getInstance().getTime();
To check that you've got the right date, the easiest way is to print
the newly created date to your console :-
System.out.println(date.toString());
I hope this helps.
Franck
Michael Nguyen wrote:
>
> I use the following approach to get the current date only without the
> curent minutes and seconds, so that I can compare the dates
> without comparing the time. However, the Date constructor is
> deprecated.
> What is the alternative and non-deprecated method of getting the
> current date without the time ?
>
> Date curr_date = new Date (calendar.get (Calendar.YEAR) - 1900,
> calendar.get (Calendar.MONTH), calendar.get
> (Calendar.DAY_OF_MONTH));
>
> Thanks for the info.
>
> Michael,
_________________________________________________________________
Franck Rasolo
Netspin Ltd Phone: +44 (0)958 750 712
7 Hill Street Fax : +44 (0)117 925 2515
Bristol BS1 5PU Email: franck@netspin.co.uk
U.K.
_________________________________________________________________
Technical Details
Message-ID:
<366F5A12.DF3930B6@netspin.co.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<366F13D2.11F2FBB9@home.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,f08bdc690f36e25a X-Google-Attributes: gidf74b3,public From: Franck Rasolo <franck@netspin.co.uk> Subject: Re: Get current date Date: 1998/12/10 Message-ID: <366F5A12.DF3930B6@netspin.co.uk> X-Deja-AN: 420700306 Content-Transfer-Encoding: 7bit References: <366F13D2.11F2FBB9@home.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Netspin Limited Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language