Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-5446

AM/PM inconsistency in mng-3827 and mng-3864 ITs?

    XMLWordPrintableJSON

Details

    • Test
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • None
    • Integration Tests
    • None

    Description

      The mng-3827 and mng-3864 ITs both include the following Date parameter in their plugin test configuration:

      <dateParam>2008-11-09 11:59:03.0 PM</dateParam>
      

      https://github.com/apache/maven-integration-testing/blob/master/core-it-suite/src/test/resources/mng-3827/pom.xml#L63
      https://github.com/apache/maven-integration-testing/blob/master/core-it-suite/src/test/resources/mng-3864/pom.xml#L69

      This parameter is then expected to be written out as:

      2008-11-09 11:59:03
      

      https://github.com/apache/maven-integration-testing/blob/master/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3827PluginConfigTest.java#L72
      https://github.com/apache/maven-integration-testing/blob/master/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3864PerExecPluginConfigTest.java#L72

      This looks odd - I would expect "23:59:03" since the time is being written back out without the AM/PM flag and

      System.err.println(new Date());

      uses the 24 hour clock on my local JVM.

      I suspect there's a long-standing bug in the Plexus DateConverter where it parses the date using a SimpleDateFormat of "yyyy-MM-dd HH:mm:ss.S a" for values with an AM/PM flag. This format uses 'HH' to parse the hour as 'Hour in day (0-23)' rather than 'hh' to parse it as 'Hour in am/pm (1-12)', which would explain why "11:59:03.0 PM" is written back as "11:59:03" and not "23:59:03".

      If that's the case then I'd like to suggest the dateParam in the mng-3827 and mng-3864 ITs is changed to:

      <dateParam>2008-11-09 11:59:03.0 AM</dateParam>
      

      because that way the result would still match the expected "11:59:03" string if/when the DateConverter is fixed (I'm doing some refactoring in the Sisu-Plexus internals to improve re-use which touches on configuration).

      AFAICT these ITs don't appear to be testing this specific Date conversion behaviour (ie. silently ignoring / dropping the PM flag), but if this isn't the case and the current behaviour should be maintained for legacy reasons then I'd also like to know.

      Thanks in advance!

      Attachments

        Issue Links

          Activity

            People

              jvanzyl Jason van Zyl
              mcculls Stuart McCulloch
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: