?
Solved

Cannot format given object as date

Posted on 2010-11-08
9
Medium Priority
?
855 Views
Last Modified: 2012-05-10
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!

0
Comment
Question by:theartha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 34084321
What about the following?
dateFormat .format(ja1.get(8).toString());

Open in new window

0
 

Author Comment

by:theartha
ID: 34084373
CEHJ: Same error.

"Cannot format given object as date"
0
 

Author Comment

by:theartha
ID: 34084444
database column type is dateTime
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 86

Expert Comment

by:CEHJ
ID: 34084465
Please post output of both of the following:
System.out.println(ja1.get(8).getClass());


System.out.println(ja1.get(8).toString());

Open in new window

0
 

Author Comment

by:theartha
ID: 34084513
class java.lang.String
2010-07-02 00:00:00.0
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 34084550
You're passing a String to format. You only pass String to parse - to turn a String into a Date. What is your intention? If it's to change the format, you need to parse first
0
 

Author Comment

by:theartha
ID: 34084618
Just to change 2010-07-02 00:00:00.0 to 070210
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34084696
:)
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 34084718
try,

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
Date date = dateFormat.parse( ja1 ) ;
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question