Link to home
Start Free TrialLog in
Avatar of jjacksn
jjacksn

asked on

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?
SOLUTION
Avatar of x4u
x4u

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
> mde.setTimeStamp(gmtFormat.parse(selectedElt.getText()));

Why aren't you just using the original Date object instead of formatting and parsing back.
Avatar of jjacksn
jjacksn

ASKER

objects, not sure what you mean...?
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?