Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-1035

DateConverter badly handles date with minus sign in TimeZone

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.0, 1.6.0
    • Fix Version/s: 1.6.0
    • Component/s: Parsing
    • Labels:
      None
    • Environment:
      Windows 7 and Fedora 14
      Java 6

      Description

      In a PDF where CreationDate is like "D:20110603085808-04'00'" (American West Coast), the method PDDocumentInformation.getCreationDate does not return a calendar with a correctly set timezone : offset remains 0.

      There is no problem with "D:20110603085808+04'00'" where offset is correct.

      The problem is in org.apache.pdfbox.util.DateConverter that does not handle '-'.

      Obvisouly, same problem with getModificationDate

      I made this patch to fix my problem :

      — DateConverter.java (revision 1133573)
      +++ DateConverter.java (working copy)
      @@ -251,6 +251,10 @@
      //parseInt cannot handle the + sign
      hours = Integer.parseInt( date.substring( 15, 17 ) );
      }
      + else if (sign == '-')
      +

      { + hours = -Integer.parseInt(date.substring(15,17)); + }

      else
      {
      hours = -Integer.parseInt( date.substring( 14, 16 ) );

      It works, but I think there is much work to do on this method.

        Attachments

          Activity

            People

            • Assignee:
              lehmi Andreas Lehmkühler
              Reporter:
              gbm.bailleul Guillaume Bailleul
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: