troubleshooting Question

Date Conversion

Avatar of TyBay
TyBay asked on
Java
16 Comments1 Solution2094 ViewsLast Modified:
Greetings.  I am working with an API in JAva that returns a Date object.  The Date object is in the below format when it is returned:
Mon Jan 22 04:47:28 PST 2007.

I need to retrieve a number of Date objects and then convert them in to the below ISO format, perhaps creating a string that can then be used in a servlet for presentation:
2007-02-24T08:09:51.

I have successfully created a new Date object and then formatted as seen below:
                    Date today = new Date();
                    String output;
                    SimpleDateFormat formatter = formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
                    output = formatter.format(today);

Unfortunately, I can’t seem to do below to get the string I need to present in the correct format:
                    String output;
                    SimpleDateFormat formatter = formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
                    output = formatter.format(MyDateToConvertFormat);

The data from the API is stored in an Oracle database and I not sure what I am missing here.  Do I need to parse the Date object before trying to format in the ISO format?  How do I create a string from the Date object that is converted in ISO?

Many Thanks
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 16 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros