Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-4454

DateProperty#toText() formatting is variable

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 2.0.1, 2.1 M1
    • 2.0
    • {Unused} Core
    • None
    • Unknown

    Description

      DateProperty holds a Date value, this value can be set directly, by clone() or by hibernate. Hibernate mapping is configured to use a timestamp (java.sql.Timestamp) while our code uses Dates (java.util.Date). This is a problem when we compare properties:

      if (!oldProperty.toText().equals(((newProperty == null) ? "" : newProperty.toText())))
      

      #toText() uses toString() and since Timestamp overrides toString() it leads to uncorrect equals() statements. I suggest a cautious fix, using a formatter (the one currently in DateProperty#getXMLString()) instead of using toString(), this way the output of #toText() would be consistent no matter the type of the DateProperty value (Timestamp or Date).

      Attachments

        Issue Links

          Activity

            People

              jvdrean Jean-Vincent Drean
              jvdrean Jean-Vincent Drean
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: