Conversion of Date into string in java when storing in database

111 views Asked by At

there is a value object processVO having date variable of string type in it( with getter & setter) .I am trying to populate it in in my DAO class in following way:- PreparedStatement.setString(processVO.getDate);
It is giving me an error as:- cannot convert Date type into String. //the value stored in processVO.getDate() is having date & time both i.e. "2-apr-2013 1:20 am"

1

There are 1 answers

0
secario On

This shouldn't be considered a good practice, but in case of simple retrieving the string you can use the toString() method on the processVO.getDate() like

processVO.getDate().toString()