Look at SimpleDateFormat class. To create a SimpleDasteFormat object that
can parse a string like "12/25/2006" into a date. Then you can create your
GregorianCalendar object from the date object.
> > I'm trying to instantiate a Date object with year, month, day, hour,
> > and minute. Any ideas? The date constructor is deprecated and
> > GregorianCalendar is the object I'm trying to use. Do you think
> > casting will work?
Casting will not work, GregorianCalendar is not derived from Date. Read
below...
> Look at SimpleDateFormat class. To create a SimpleDasteFormat object that
> can parse a string like "12/25/2006" into a date. Then you can create your
> GregorianCalendar object from the date object.
You ignore Hal Rosser's bad advice, and do the correct thing by using:
GregorianCalendar calendar = new GragorianCalendar(year, month, day,
hour, minute);
Date date = .calendar.getTime();
If you look in the API javadoc, you might have been able to figure that
out yourself. I suggest you try that next time for a quicker response.
:-)
Good luck.
- Daniel
Mike - 06 Nov 2006 13:05 GMT
Thanks Daniel,
I was a bit confused honestly from looking at the javadoc. I assumed
that .getTime() would get the system's time. My assumptions were the
least bit educated. Thanks.
> > > I'm trying to instantiate a Date object with year, month, day, hour,
> > > and minute. Any ideas? The date constructor is deprecated and
[quoted text clipped - 19 lines]
> Good luck.
> - Daniel