Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[stellation-res] Timestamp handling

There are a number of places where we are using the following sequence of
code that leads to problems and inefficiency.

Date t = // get from somewhere
attributes.put("time", t.toString());
  .
  .
  .
  .
Date date = null;
try {
  date = DateFormat.getDateInstance().parse(attributes.get("time"));
}
catch (ParseException pe) {
 logger.debug("Invalid date in attribute: " + attributes.get("time") + ",
using now as default");
   date = new Date();
}

This code is failing everywhere sice DateFormat.parse() cannot handle the
output from Date.toString(). In addition it is very expensive in processing
and resultsa in losing information. I believe that we should use the Date
objects directly instead of the string representation, and when we need to
write externally (e.g. to XML files we should write the long integer
representation of the date.

Thoughts?

Regards

Jonathan



Back to the top