Question: I am storing my 2 Java date types as Date and Time for a MySQL database table. I am using the `SimepleDateFormat("YYYY-MM-dd")` to store the date in my database and it shows up as the correct date when i go to select it. However when i try to parse it back into a util.Date and create a new Event Object, it shows up as `30/12/2012` instead of `31/05/2013` as it is in the database. The time, when parsed into a util.Date and formatted prints out correctly. I am not sure why the Date is printing the wrong date, but the time is printing the correct time.

Database

```
+--------+--------------+-----------+
+ EVENT1 +  2013-05-31  +  02:30:00 +
+--------+--------------+-----------+
+ EVENT2 +  2013-05-31  +  01:00:00 +
+--------+--------------+-----------+

```

Prints:

```
Event1
30/12/2012
02:30
Event2
30/12/2012
01:00

```

Answer: 
try

```
String testDate = "2007-11-02T14:46:03";
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
Date date = formatter.parse(testDate);

```

But better way to store in database is to use timestamp instead of storing date and time separately
try this...

```
SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd");   
Date date =  dateFormat.parse(rs.getDate(2).toString());

```