Hi,
Is there a way to do the following without using the deprecated Date
constructor Date(String)?
Calendar calendar = new GregorianCalendar();
Date d = new Date("Friday, 24 March 2006");
calendar.setTime(d);
thanks
Andy
Robert Klemme - 24 Mar 2006 15:09 GMT
> Hi,
>
[quoted text clipped - 4 lines]
> Date d = new Date("Friday, 24 March 2006");
> calendar.setTime(d);
http://java.sun.com/j2se/1.4.2/docs/api/java/text/DateFormat.html#parse(java.lan
g.String)
robert
Nils Bandener - 24 Mar 2006 15:11 GMT
Hi!
> Is there a way to do the following without using the deprecated Date
> constructor Date(String)?
>
> Calendar calendar = new GregorianCalendar();
> Date d = new Date("Friday, 24 March 2006");
> calendar.setTime(d);
Yep, using java.text.SimpleDateFormat:
Calendar calendar = new GregorianCalendar();
SimpleDateFormat format = new SimpleDateFormat("E, d M y");
Date d = format.parse("Friday, 24 March 2006");
calendar.setTime(d);
(You'll have to handle some exceptions, see the API doc for these)
Bye
Nils
Roedy Green - 24 Mar 2006 19:50 GMT
>Is there a way to do the following without using the deprecated Date
>constructor Date(String)?
see http://mindprod.com/jgloss/calendar.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
John O'Conner - 24 Mar 2006 22:02 GMT
> Hi,
>
[quoted text clipped - 4 lines]
> Date d = new Date("Friday, 24 March 2006");
> calendar.setTime(d);
Calendar calendar = Calendar.getInstance();
calendar.set(2006, Calendar.MARCH, 24);
Date d = calendar.getTime();
How's that?
Regards,
John O'Conner