[
https://issues.apache.org/jira/browse/PDFBOX-6119?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18044603#comment-18044603
]
Tilman Hausherr edited comment on PDFBOX-6119 at 12/12/25 7:27 AM:
-------------------------------------------------------------------
Thanks, I agree that this code is complicated. However your the test fails on
jdk8 in pdfbox 3:
{noformat}
java.lang.IllegalArgumentException: Invalid zone offset pattern: +HH:mm:ss
at
java.time.format.DateTimeFormatterBuilder$OffsetIdPrinterParser.checkPattern(DateTimeFormatterBuilder.java:3341)
at
java.time.format.DateTimeFormatterBuilder$OffsetIdPrinterParser.<init>(DateTimeFormatterBuilder.java:3331)
at
java.time.format.DateTimeFormatterBuilder.appendOffset(DateTimeFormatterBuilder.java:925)
at org.apache.xmpbox.DateConverter.fromISO8601(DateConverter.java:343)
at org.apache.xmpbox.DateConverter.toCalendar(DateConverter.java:111)
at
org.apache.xmpbox.DateConverterTest.testDateFormatting(DateConverterTest.java:157)
at java.lang.reflect.Method.invoke(Method.java:498)
at java.util.ArrayList.forEach(ArrayList.java:1259)
at java.util.ArrayList.forEach(ArrayList.java:1259)
{noformat}
was (Author: tilman):
Thanks, I agree that this code is complicated. However your the test fails on
jdk8 in pdfbox 3:
Running org.apache.xmpbox.DateConverterTest
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.101 s <<<
FAILURE! -- in org.apache.xmpbox.DateConverterTest
org.apache.xmpbox.DateConverterTest.testDateFormatting -- Time elapsed: 0.048 s
<<< ERROR!
java.lang.IllegalArgumentException: Invalid zone offset pattern: +HH:mm:ss
at
java.time.format.DateTimeFormatterBuilder$OffsetIdPrinterParser.checkPattern(DateTimeFormatterBuilder.java:3341)
at
java.time.format.DateTimeFormatterBuilder$OffsetIdPrinterParser.<init>(DateTimeFormatterBuilder.java:3331)
at
java.time.format.DateTimeFormatterBuilder.appendOffset(DateTimeFormatterBuilder.java:925)
at org.apache.xmpbox.DateConverter.fromISO8601(DateConverter.java:343)
at org.apache.xmpbox.DateConverter.toCalendar(DateConverter.java:111)
at
org.apache.xmpbox.DateConverterTest.testDateFormatting(DateConverterTest.java:157)
at java.lang.reflect.Method.invoke(Method.java:498)
at java.util.ArrayList.forEach(ArrayList.java:1259)
at java.util.ArrayList.forEach(ArrayList.java:1259)
org.apache.xmpbox.DateConverterTest.testDateConversion -- Time elapsed: 0.011 s
<<< ERROR!
java.lang.IllegalArgumentException: Invalid zone offset pattern: +HH:mm:ss
at
java.time.format.DateTimeFormatterBuilder$OffsetIdPrinterParser.checkPattern(DateTimeFormatterBuilder.java:3341)
at
java.time.format.DateTimeFormatterBuilder$OffsetIdPrinterParser.<init>(DateTimeFormatterBuilder.java:3331)
at
java.time.format.DateTimeFormatterBuilder.appendOffset(DateTimeFormatterBuilder.java:925)
at org.apache.xmpbox.DateConverter.fromISO8601(DateConverter.java:343)
at org.apache.xmpbox.DateConverter.toCalendar(DateConverter.java:111)
at
org.apache.xmpbox.DateConverterTest.testDateConversion(DateConverterTest.java:88)
at java.lang.reflect.Method.invoke(Method.java:498)
at java.util.ArrayList.forEach(ArrayList.java:1259)
at java.util.ArrayList.forEach(ArrayList.java:1259)
> DateConverter fails on valid date
> ---------------------------------
>
> Key: PDFBOX-6119
> URL: https://issues.apache.org/jira/browse/PDFBOX-6119
> Project: PDFBox
> Issue Type: Bug
> Components: XmpBox
> Affects Versions: 3.0.7 PDFBox
> Reporter: Andrea Vacondio
> Priority: Minor
> Labels: date, parse, xmp
> Attachments: xmp-date-patch-1.diff, xmp-date.xml
>
> Original Estimate: 0.25h
> Remaining Estimate: 0.25h
>
> I think there is an issue with the DateConverter in XMPBox. Consider the
> following:
> {code:xml}
> <xmp:CreateDate>2024-04-09T14:41:38</xmp:CreateDate>
> <xmp:ModifyDate>2015-02-02T16:37:19.192Europe/Berlin</xmp:ModifyDate>
> {code}
> The first is a valid date, according to the XMP spec chapter 8.2.1.2 "The
> time zone designator need not be present in XMP. When not present, the time
> zone is unknown, and an
> XMP processor should not assume anything about the missing time zone"
> The second is invalid, according to the spec "TZD = time zone designator (Z
> or +hh:mm or -hh:mm)"
> Adobe XMPCore parses the first one as if it's UTC and fails on the second
> while XMPBox fails on the first and parses the second.
> The DateConverter::fromISO8601 method is responsible for parsing the date
> string, it's quite complicated and error prone, likely because it comes from
> ancient ages. In my opinion, it could be greatly simplified using what's
> provided by the JDK and also fix the behavior to parse the first date and
> fail on the second like XMPCore does.
> The only caveat is that the first date will be considered as UTC because we
> can't have a Calendar without time zone so we can't comply with the "should
> not assume anything about the missing time zone", but that's also what
> XMPCore does.
> I added a patch and modified the tests, all test pass.
> If you prefer to keep the current behavior, it should at least be modified to
> support the first valid date string.
> I also attached the original xmp stream found in the document.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]