You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Guillaume Bailleul (JIRA)" <ji...@apache.org> on 2011/06/09 00:57:58 UTC

[jira] [Created] (PDFBOX-1035) DateConverter badly handles date with minus sign in TimeZone

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

[jira] [Resolved] (PDFBOX-1035) DateConverter badly handles date with minus sign in TimeZone

Posted by "Andreas Lehmkühler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-1035?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Lehmkühler resolved PDFBOX-1035.
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.6.0
         Assignee: Andreas Lehmkühler

I fixed this in revision 1135144 as proposed.

Thanks for the contribution!

> 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
>            Assignee: Andreas Lehmkühler
>            Priority: Minor
>             Fix For: 1.6.0
>
>
> 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