how to write a date to a string

I'm trying to read/write a date to a string via the following method:

      private static DateFormat gmtFormat;                   
      static {
            gmtFormat = DateFormat.getDateInstance(DateFormat.FULL, Locale.US);
            gmtFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
      }

and then later

writeChildElement(elt, "TimeStamp", gmtFormat.format(timeStamp));
mde.setTimeStamp(gmtFormat.parse(selectedElt.getText()));

But, it looks like the lower order numbers or removed from the value when I watch the Date object in the debugger.  Is there a string representation that is human readable that i can use?
LVL 5
jjacksnAsked:
Who is Participating?
 
objectsCommented:
You can use SimpleDateFormat to format it in whatever formnat you want
0
 
x4uCommented:
DateFormat.getDateInstance() does not format the time part of the date, you need to use DateFormat.getDateTimeInstance().

gmtFormat = DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.FULL, Locale.US);
0
 
objectsCommented:
> mde.setTimeStamp(gmtFormat.parse(selectedElt.getText()));

Why aren't you just using the original Date object instead of formatting and parsing back.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
Manikandan ThiagarajanSenior consultantCommented:
0
 
jjacksnAuthor Commented:
objects, not sure what you mean...?
0
 
objectsCommented:
you're talkikng a date and formatting it as a string then back to a date again.
Why can't you just use the original date instance instead of parsing the string?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.