Uploaded image for project: 'Magnolia UI'
  1. Magnolia UI
  2. MGNLUI-4271

DateField: default value can not be set -> yaml parses the Date (and Time) String automatically

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an issue
    • Icon: Neutral Neutral
    • None
    • 5.5.5
    • forms
    • None

      Configuring on a DateFieldDefintion a default value like this defaultValue: 2015-01-01 throws an exception:

      Caused by: java.text.ParseException: Unparseable date: "Thu Jan 01 01:00:00 CET 2015"
      	at java.text.DateFormat.parse(DateFormat.java:366)
      	at info.magnolia.ui.vaadin.integration.jcr.DefaultPropertyUtil.createTypedValue(DefaultPropertyUtil.java:164)
      	... 137 more
      

      The reason:
      Yaml seems to automatically parse String representations of Date (and of Time).
      Regarding Date:
      Adding a Date value as String to the yaml defaultValue: 2015-01-01 and reading the String directly from the defintion it returns this Thu Jan 01 01:00:00 CET 2015.
      When its not matching the Date formate it returns the String 1:1, for example: Adding this value to the yaml defaultValue: 2015.01.01 and reading the String directly from the defintion it returns this {2015.01.01}}.

      Regarding Time:
      Adding a Time value as String to the yaml example: 11:00 and reading the String directly from the defintion it returns this 660 (which is a wrong int representation!).
      When its not matching the Time formate it returns the String 1:1, for example: Adding this value to the yaml example: 11.00 and reading the String directly from the defintion it returns this {11.00}}.

        Acceptance criteria

              Unassigned Unassigned
              cringele Christian Ringele
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD