[osmosis-dev] Get underlying timestamp string

Brett Henderson brett at bretth.com
Wed Nov 24 08:47:50 GMT 2010


Hi Rafael,

On Tue, Nov 23, 2010 at 8:37 PM, Rafael Troilo <rtroilo at gmail.com> wrote:

> Hello,
>
> At the moment I use:
>
> XmlTimestampFormat xmlTimestampFormat = new XmlTimestampFormat();
> TimestampContainer tc = entity.getTimestampContainer();
> String timestamp = tc.getFormattedTimestamp(xmlTimestampFormat);
>
> to get the timestamp string out of the xml file without parsing. (be
> sure enableDateParsing is not disabled)
> But this leads me to a dependency to the osmosis-xml plugin, what I
> don't really want.
>
So, it would be very nice, if we could supply a null value to
> UnparsedTimestampContainer.getFormattedTimestamp(..) to get the
> underlying timestampString without parsing.
>
> Here my suggestion:
>
> public String getFormattedTimestamp(TimestampFormat timestampFormat) {
>     if (timestampString != null &&
>         (timestampFormat == null ||
>          managedTimestampFormat.isEquivalent(timestampFormat))) {
>      return timestampString;
>     }
>   ...
> }
>

What is your reason for avoiding a dependency on osmosis-xml?  What you want
is the date in XML timestamp format, so introducing a dependency on the
Osmosis XML classes doesn't seem like such a big issue.  The reason I
designed it that was was precisely to prevent anybody making assumptions
about the internal date string format.  It's a fairly safe be to assume that
the osmosis XML libs will always be available in the Osmosis distribution.

This way you're forced to say you want the string in XML format, and if the
string is already in that format no conversion will be required.  If it
happens to be in an alternate format or there is no string representation
available then the conversion will be automatic.  At least that's what I
think it's supposed to do, it's been a while since I wrote that bit ;-)

Brett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/osmosis-dev/attachments/20101124/41ffde5e/attachment.html>


More information about the osmosis-dev mailing list