[ 
https://issues.apache.org/jira/browse/PDFBOX-1633?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13813123#comment-13813123
 ] 

Andreas Lehmkühler commented on PDFBOX-1633:
--------------------------------------------

Thanks for coming back that fast, but some of the unit tests still fail.

checkParse(year+20, 7, 6, 0, 0, 0, 0, "7/6/" + ((year+20)%100));   

produces the following output:

junit.framework.ComparisonFailure: null expected:<[20]33-07-06T00:00:00+00...> 
but was:<[19]33-07-06T00:00:00+00...>
        at junit.framework.Assert.assertEquals(Assert.java:81)
        at junit.framework.Assert.assertEquals(Assert.java:87)
        at org.apache.pdfbox.util.TestDateUtil.checkParse(TestDateUtil.java:151)
        at 
org.apache.pdfbox.util.TestDateUtil.testDateConverter(TestDateUtil.java:265)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at junit.framework.TestCase.runTest(TestCase.java:168)
        at junit.framework.TestCase.runBare(TestCase.java:134)
        at junit.framework.TestResult$1.protect(TestResult.java:110)
        at junit.framework.TestResult.runProtected(TestResult.java:128)
        at junit.framework.TestResult.run(TestResult.java:113)
        at junit.framework.TestCase.run(TestCase.java:124)
        at junit.framework.TestSuite.runTest(TestSuite.java:232)
        at junit.framework.TestSuite.run(TestSuite.java:227)
        at 
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
        at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
        at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)



> DateConverter needs to work
> ---------------------------
>
>                 Key: PDFBOX-1633
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1633
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 1.8.2
>         Environment: all os and java platforms
>            Reporter: Fred Hansen
>             Fix For: 1.8.3, 2.0.0
>
>         Attachments: DateConverter.java, TestDateUtil.java
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Most of the tests for org/apache/pdfbox/util/DateConverter.java in 
> src/test/java/org/apache/pdfbox/util/TestDateUtil.java have been commented 
> out.  DateConverter was broken.
> The attached patch fixes the problems.  Extensive comments document the 
> problems. Here's a copy:
> /* the former version of DateConverter had these bugs:
>  *   -  In toISO8601 the conversion from millis to minutes was with 1000/1000;
>  *      should have been 1000/60.
>  *   -  PDFBox-402 was not completely implemented. The calendar fields in the
>  *      POTENTIAL_FORMATS are shared among threads. Hence we must create new
>  *      SimpleThreadFormats for each test.  (Or synchronize somehow).
>  *   -  Some formats with hh did not have an a field. I changed them to HH.
>  * 
>  *  these questionable features:
>  *   -  A timezone with neither plus sign nor minus is assumed to be minus.
>  *      This seems wrong, but I have not changed it.
>  *   -  toCalendar() returned a value in the default Locale.
>  *      PDF files do not have locales (I think) and even if they do
>  *      there is no reason to assume the Java default.
>  *      I have switched to Locale.ENGLISH which was already assumed 
>  *      in the date formats and toString.
>  * 
>  * and these infelicities:
>  *   -  Constants 60 and 1000 appeared.
>  *   -  zeroAppend was not used where applicable.
>  *      In one case it was inapplicable only because TimeZone.getOffset 
>  *      was suspected of returning a long. It does not.
>  *   -  Manually computed constants were used to in date.substring
>  *      thus reducing flexibility and maintainability. 
>  *   -  The TimeZone name reported by toCalendar was always "Unknown"
>  *      It is easy enough to compute a name.
>  *   -  Time zones were not accepted with most of the alternate parsing 
> formats.
>  *      The new code allows a timezone after any format.
>  */



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to