[opencms-dev] How to convert/use a String field as a Date field?
Jose Ignacio Yarza
jiyarza at opensistemas.com
Thu Apr 26 12:38:52 CEST 2012
Briefly, this is about finding a good strategy for
migrating/converting/using a string field as a date field for all the
xml content in a production site (opencms 7.5.0, ~3gb).
Long story. A field of type OpenCmsString is storing a DATE with the
<xsd:element name="EventDate" type="OpenCmsString" minOccurs="1"
We need it as OpenCmsDateTime for sorting and other business logic.
So far, I am looking at these options:
1- Create a new field of type OpenCmsDateTime and convert and copy the
value through a java task or some other way. It's tricky and dirty,
because from then on it will be necessary to keep both fields
synchronized in the code. And eventually get rid of the string version.
2- Create a custom collector with a comparator to order the string field
as date instead of alphabetically. This would solve the listings and I
think this is cleaner, but I am not all that happy to keep the field as
I am unsure about both. I was wondering if we can get somewhere mapping
the field to a property such as releasedate, as it is, or if we could
perform a conversion somewhere, before the mapping.
So, before I set sail to these swampy waters, I would like some advice
from ye ol' wise List.
Thank you so much.
Jose Ignacio Yarza Vidal
Telf: 649 157 537
More information about the opencms-dev