Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-1845

Only date is returned wihen both dateStyle and timeStyle are set without specifying type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.2.2
    • 1.2.3
    • None
    • None
    • MyFaces 1.2.2

    Description

      Given the following snippet, MyFaces should be rendering both the date and time but only renders the date.

      <h:outputText value="#

      {MyBean.someTime}

      ">
      <f:convertDateTime dateStyle="full" timeStyle="full" />
      </h:outputText>

      According to the spec, if type is not specified:
      ■ if dateStyle is set and timeStyle is not, type defaults to date
      ■ if timeStyle is set and dateStyle is not, type defaults to time
      ■ if both dateStyle and timeStyle are set, type defaults to both

      The 1.2.2 implemtation always returns date. I believe the problem is in the getType method of javax.faces.convert.DateTimeConverter.

      Currently, anytime _type is null, its returning TYPE_DATE.
      return _type != null ? _type : TYPE_DATE;

      What might better comply with the spec would be to do something like this:
      if(_type == null){
      if(_dateStyle != null && _timeStyle != null)

      { return TYPE_BOTH; }

      else if(_timeStyle != null)

      { return TYPE_TIME; }

      else

      { return TYPE_DATE; }


      }
      return _type;

      I've tested this code locally and it does fix the above behavior.

      Attachments

        Activity

          People

            lu4242 Leonardo Uribe
            mconcini Michael Concini
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: