DateConverter badly handles date with minus sign in TimeZone
------------------------------------------------------------

                 Key: PDFBOX-1035
                 URL: https://issues.apache.org/jira/browse/PDFBOX-1035
             Project: PDFBox
          Issue Type: Bug
          Components: Parsing
    Affects Versions: 1.5.0, 1.6.0
         Environment: Windows 7 and Fedora 14
Java 6 
            Reporter: Guillaume Bailleul
            Priority: Minor


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. 



--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to