Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-21009

Cannot set section time while use non-English locale.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: CLOSED
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.8.0
    • Fix Version/s: 2.8.2, 2.9.0
    • Labels:
      None
    • Environment:
      JAVAOPTS: -Duser.language=zh -Duser.region=CN"
    • CLE Team Issue:
      Yes

      Description

      While setting time of a section in non-English locale, it will generate a RuntimeException. Its hint is "A bad date made it through validation! This should never happen!". But unfortunately, it happens.
      In /sections/sections-app-util/src/java/org/sakaiproject/tool/section/jsf/JsfUtil.java convertStringToTime(String str, boolean am), An suffix either "AM" or "PM" is added according to the param. And the result string will be parsed to date by user locale(new ResourceLoader().getLocale(), line 197). Since not all locale use AM/PM (zh_CN for example), it will cause a "never happen" exception.

      The solution of this bug is just change the line 197
      SimpleDateFormat sdf = new SimpleDateFormat(pattern, new ResourceLoader().getLocale());
      to US locale which use AM/PM
      SimpleDateFormat sdf = new SimpleDateFormat(pattern, Locale.US);

        Gliffy Diagrams

          Zeplin

            Attachments

            1. am-pm01.jpg
              am-pm01.jpg
              54 kB
            2. am-pm02.jpg
              am-pm02.jpg
              63 kB
            3. idea.patch.txt
              2 kB
            4. idea2.patch.txt
              1 kB
            5. sections_SAK-21009.patch.txt
              1 kB

              Issue Links

                Activity

                  People

                  Assignee:
                  darolmar@abierta.upv.es David Roldán Martínez
                  Reporter:
                  gaojun Gao Jun
                  Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                    Dates

                    Created:
                    Updated:
                    Resolved:

                      Git Integration