theartha
asked on
Cannot format given object as date
Hi There,
I am retrieving a value from database
2010-07-02 00:00:00.0 as json object and I am trying to convert it into Java Date using
SimpleDateFormat dateFormat = new SimpleDateFormat("MMddyy") ;
dateFormat .format(ja1.get(8);
I received the below error.
"Cannot format given object as date "
any clues?
Thanks!
I am retrieving a value from database
2010-07-02 00:00:00.0 as json object and I am trying to convert it into Java Date using
SimpleDateFormat dateFormat = new SimpleDateFormat("MMddyy")
dateFormat .format(ja1.get(8);
I received the below error.
"Cannot format given object as date "
any clues?
Thanks!
ASKER
CEHJ: Same error.
"Cannot format given object as date"
"Cannot format given object as date"
ASKER
database column type is dateTime
Please post output of both of the following:
System.out.println(ja1.get(8).getClass());
System.out.println(ja1.get(8).toString());
ASKER
class java.lang.String
2010-07-02 00:00:00.0
2010-07-02 00:00:00.0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Just to change 2010-07-02 00:00:00.0 to 070210
:)
try,
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM- dd HH:mm:ss.S");
Date date = dateFormat.parse( ja1 ) ;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-
Date date = dateFormat.parse( ja1 ) ;
Open in new window