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

Bug in org.apache.myfaces.custom.date.HtmlInputDate (misinterprets 12:xx )

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.1.1
    • None
    • None

    Description

      In method parse() the date is parsed as follows:
      SimpleDateFormat fullFormat = new SimpleDateFormat( "dd MM yyyy HH mm ss" );
      if (timeZone != null)
      fullFormat.setTimeZone(timeZone);
      return fullFormat.parse(day+" "month" "year" "hours" "minutes" "+seconds);

      This is normally no problem, but when the variable "hours" is "12", SimpleDateFormat "misinterprets" this value and thinks it's 12 AM, but the user normally intendet 12 PM (using a 24h clock). This can be solved by using the following routine instead:

      Calendar tempCalendar=Calendar.getInstance();
      if (timeZone != null)
      tempCalendar.setTimeZone(timeZone);
      tempCalendar.set(Calendar.DAY_OF_MONTH,Integer.parseInt(day));
      tempCalendar.set(Calendar.MONTH,Integer.parseInt(month)-1);
      tempCalendar.set(Calendar.YEAR,Integer.parseInt(year));
      tempCalendar.set(Calendar.HOUR_OF_DAY,Integer.parseInt(hours));
      tempCalendar.set(Calendar.MINUTE,Integer.parseInt(minutes));
      return tempCalendar.getTime();
      }

      Attachments

        Activity

          People

            bruno_dev Bruno Aranda
            marcel.urbanek Marcel Urbanek
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: