Home > Archive > Java Help > March 2004 > How do you create a Date object that represents the time?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How do you create a Date object that represents the time?
|
|
|
| Could you please help me with this question?
Please, your assistance is much appreciated!
Zayda
| |
| Andrew Thompson 2004-03-29, 4:37 pm |
| On 29 Mar 2004 12:56:49 -0800, Zayda wrote:
Best to repeat the subject as first line..
'How do you create a Date object
that represents the time?'. But..
> Could you please help me with this question?
...that is rather redundant for a help group!
> Please, your assistance is much appreciated!
OK, OK, stop begging! Try..
java.util.Date theTimeIsNo_TheSmiths =
new Date( System.currentTimeMillis() );
HTH
--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
| |
| Andrew Thompson 2004-03-29, 5:39 pm |
| On Mon, 29 Mar 2004 21:08:52 GMT, Andrew Thompson wrote:
> java.util.Date theTimeIsNo_TheSmiths =
correction..
java.util.Date howSoonIsNow_TheSmiths =
Where was my head at? ;-)
| |
| Roedy Green 2004-03-29, 11:33 pm |
| On 29 Mar 2004 12:56:49 -0800, zayda@btinternet.com (Zayda) wrote or
quoted :
>Could you please help me with this question?
See various Date constructors.
See http://mindprod.com/jgloss/calendar.html for an introduction to
the mysteries of date and time.
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
| |
| Roedy Green 2004-03-29, 11:33 pm |
| On Mon, 29 Mar 2004 21:12:34 GMT, Andrew Thompson
<SeeMySites@www.invalid> wrote or quoted :
>correction..
>java.util.Date howSoonIsNow_TheSmiths =
I think you meant to say:
// automatically initialised to now.
java.util.Date howSoonIsNow_TheSmiths = new Date();
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
| |
| Jon A. Cruz 2004-03-30, 12:33 am |
| Andrew Thompson wrote:
>
> OK, OK, stop begging! Try..
>
> java.util.Date theTimeIsNo_TheSmiths =
> new Date( System.currentTimeMillis() );
java.util.Date theTimeIs = new java.util.Date();
That extra call is not needed. Check the JavaDoc for the no-args
constructor.
| |
| Andrew Thompson 2004-03-30, 6:37 am |
| On Tue, 30 Mar 2004 03:17:25 GMT, Roedy Green wrote:
> On Mon, 29 Mar 2004 21:12:34 GMT, Andrew Thompson
> <SeeMySites@www.invalid> wrote or quoted :
>
>
> I think you meant to say:
> // automatically initialised to now.
> java.util.Date howSoonIsNow_TheSmiths = new Date();
Well wouldn't you know..
(shakes head) These new _fangled_ no args
constructors ..next thing you know they'll
have 'heavier than air' flying machines!
| |
| Bryce (Work) 2004-03-30, 10:49 am |
| On Mon, 29 Mar 2004 21:08:52 GMT, Andrew Thompson
<SeeMySites@www.invalid> wrote:
>On 29 Mar 2004 12:56:49 -0800, Zayda wrote:
>
>Best to repeat the subject as first line..
>'How do you create a Date object
>that represents the time?'. But..
>
>
>..that is rather redundant for a help group!
>
>
>OK, OK, stop begging! Try..
>
>java.util.Date theTimeIsNo_TheSmiths =
> new Date( System.currentTimeMillis() );
or the non-deprecated way:
Calendar calendar = new GregorianCalendar();
calendar.getTime();
--
now with more cowbell
| |
|
|
|
|
| Alex Hunsley 2004-03-31, 4:58 am |
| Andrew Thompson wrote:
> On 29 Mar 2004 12:56:49 -0800, Zayda wrote:
>
> Best to repeat the subject as first line..
> 'How do you create a Date object
> that represents the time?'. But..
>
>
>
>
> ..that is rather redundant for a help group!
>
>
>
>
> OK, OK, stop begging! Try..
>
> java.util.Date theTimeIsNo_TheSmiths =
> new Date( System.currentTimeMillis() );
>
> HTH
Hmm.. how _soon_ is now? Surely the answer
would be:
long now = System.currentTimeMillis();
java.util.Date theTimeIsNo_TheSmiths =
new Date( now - now );
however, 'soonness' isn't a date, and if you ran the above code, the
answer to "how soon is now" would be '1970'. Maybe that's the answer!
alex
|
|
|
|
|