java.util.Date deprecated

Hi, inside my bean i have an attribute

private Date fec_estado;

when i want to set a value on that attribute :

tempUsuario.setFec_estado(new Date(res.getObject(7).toString()));

it gives me a warning and it says that the java.util.Date(java.lang.String) has been deprecated..

So what should i use....should i keep using java.util.Date or what?

[446 byte] By [pompeighuIIa] at [2007-11-27 6:36:43]
# 1
Read the manual: http://java.sun.com/j2se/1.4.2/docs/api/java/util/Date.html#Date(java.lang.String)
JoachimRohdea at 2007-7-12 18:04:42 > top of Java-index,Java Essentials,Java Programming...
# 2

Date is not deprecated, but many of its methods are. If you want to turn a String into a Date, use SimpleDateFormat.

[url=http://www.javaworld.com/jw-12-2000/jw-1229-dates.html]Calculating Java dates: Take the time to learn how to create and use dates[/url]

[url=http://www.javaalmanac.com/egs/java.text/FormatDate.html]Formatting a Date Using a Custom Format[/url]

[url=http://www.javaalmanac.com/egs/java.text/ParseDate.html]Parsing a Date Using a Custom Format[/url]

jverda at 2007-7-12 18:04:42 > top of Java-index,Java Essentials,Java Programming...
# 3

You can use the Calendar instead.

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html

For setting its value you have several options:

//get current time

Calendar cal = Calendar.getInstance();

//set some field (google to read about the maya's predicting some big things //happen at the year 2012)

cal.set(Calendar.YEAR, 2012);

//convert to Date

Date date = cal.getTime();

//...

cappelleha at 2007-7-12 18:04:42 > top of Java-index,Java Essentials,Java Programming...