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
new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy")