New date ("05-MAY-09 03.55.50") - is there something wrong with that? i am getting illegalArgumentException
5 answers
That the Date constructor is deprecated for some reason.
You should use DateFormat / SimpleDateFormat instead to create Date instances from String representation.
DateFormat df = new SimpleDateFormat("dd-MMM-yy hh.mm.ss");
Date myDate = df.parse("05-05-MAY-09 03.55.50");
This way, you can parse dates that are in almost any format you might want.
+14
a source to share
Apart from using the deprecated method (you must use SimpleDateFormat ) this should work:
new Date("05-MAY-09 03:55:50");
Also check out Joda Time
+2
a source to share
This constructor is deprecated (since jdk 1.1).
This is not even relevant in java5
http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Date.html
You should
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
Date date = sdf.parse("05-MAY-09 03:55:50");
0
a source to share