Home > Archive > Java Help > March 2004 > Calendar Class
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]
|
|
|
| This is probably a RTFM style answer but I've tried for hours with no
success to answer this really simple question.
What kind of argument/format (aside from a value of type long ) do you pass
to the setTime method in the Calendar class?
is something along the lines of YYYYMMDDHHMMSS ?
ergo. setTime(20040324234934)
Thanks,
Ben.
| |
| Ryan Stewart 2004-03-27, 12:30 am |
| "Princess Morgiah" <princess_morgiah_nospamplease@yahoo.com> wrote in
message news:Hxi8c.47859$5u1.3232827@phobos.telenet-ops.be...
> "Ben" <dontwant@togetspam.com> wrote in message
> news:4061b01f$1@funnel.arach.net.au...
> pass
>
> Hi Ben,
>
> If I remember correctly, setTime accepts a long value representing the
time
> in milliseconds.
>
> Have a look at System.currentTimeMillis(), this gives you the current
> date/time. Straight from the doc:
> "the difference, measured in milliseconds, between the current time and
> midnight, January 1, 1970 UTC"
>
> Hope this helps,
>
> Princess Morgiah
>
Actually, setTime accepts a Date object. The setTimeInMillis accepts a long.
To the OP: there is no "format". As the Princess pointed out, you pass the
number of milliseconds since 1 Jan 1970 or you can use a Date object.
| |
|
| Thanks Ryan and Princess Morgiah for you help. Much appreciated.
I realised I was barking up the wrong tree with the Calendar class. See me
other post about calculating time difference.
Thanks again,
Ben.
"Ryan Stewart" <zzanNOtozz@gSPAMo.com> wrote in message
news:Qf-dnZ3VOKiLXvzdRVn-vA@texas.net...
> "Princess Morgiah" <princess_morgiah_nospamplease@yahoo.com> wrote in
> message news:Hxi8c.47859$5u1.3232827@phobos.telenet-ops.be...
> time
> Actually, setTime accepts a Date object. The setTimeInMillis accepts a
long.
> To the OP: there is no "format". As the Princess pointed out, you pass the
> number of milliseconds since 1 Jan 1970 or you can use a Date object.
>
>
| |
| Bryce (Work) 2004-03-27, 12:30 am |
| On Wed, 24 Mar 2004 23:50:17 +0800, "Ben" <dontwant@togetspam.com>
wrote:
>This is probably a RTFM style answer but I've tried for hours with no
>success to answer this really simple question.
>
>What kind of argument/format (aside from a value of type long ) do you pass
>to the setTime method in the Calendar class?
>
>is something along the lines of YYYYMMDDHHMMSS ?
>
>ergo. setTime(20040324234934)
Calendar calendar = new GregorianCalendar();
// Sets calendar to May 18, 2004
calendar.set(2004, Calendar.MAY, 18);
// If you need more precise settings...
// Sets calendar to May 18, 2004 at 8:45:15 AM
calendar.set(2004, Calendar.MAY, 18, 8, 45, 15);
--
now with more cowbell
| |
| Princess Morgiah 2004-03-28, 12:01 am |
| "Ben" <dontwant@togetspam.com> wrote in message
news:4061b01f$1@funnel.arach.net.au...
> This is probably a RTFM style answer but I've tried for hours with no
> success to answer this really simple question.
>
> What kind of argument/format (aside from a value of type long ) do you
pass
> to the setTime method in the Calendar class?
>
> is something along the lines of YYYYMMDDHHMMSS ?
>
> ergo. setTime(20040324234934)
Hi Ben,
If I remember correctly, setTime accepts a long value representing the time
in milliseconds.
Have a look at System.currentTimeMillis(), this gives you the current
date/time. Straight from the doc:
"the difference, measured in milliseconds, between the current time and
midnight, January 1, 1970 UTC"
Hope this helps,
Princess Morgiah
|
|
|
|
|