diff --git a/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLProperties.java b/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLProperties.java index ca28affdbf..7ccbe771d7 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLProperties.java +++ b/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLProperties.java @@ -276,7 +276,7 @@ public class POIXMLProperties { public void setCreated(Optional date) { part.setCreatedProperty(date); } - public void setCreated(String date) { + public void setCreated(String date) throws InvalidFormatException { part.setCreatedProperty(date); } public String getCreator() { @@ -309,7 +309,7 @@ public class POIXMLProperties { public void setLastPrinted(Optional date) { part.setLastPrintedProperty(date); } - public void setLastPrinted(String date) { + public void setLastPrinted(String date) throws InvalidFormatException { part.setLastPrintedProperty(date); } /** @since POI 3.15 beta 3 */ @@ -326,7 +326,7 @@ public class POIXMLProperties { public void setModified(Optional date) { part.setModifiedProperty(date); } - public void setModified(String date) { + public void setModified(String date) throws InvalidFormatException { part.setModifiedProperty(date); } public String getSubject() { diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageProperties.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageProperties.java index 0c5aa55731..579c68fdb1 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageProperties.java +++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/PackageProperties.java @@ -17,6 +17,8 @@ package org.apache.poi.openxml4j.opc; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; + import java.util.Date; import java.util.Optional; @@ -102,8 +104,10 @@ public interface PackageProperties { /** * Set the date of creation of the resource. + * @throws InvalidFormatException only since POI 5.2.0, used to throw unchecked exception + * IllegalArgumentException if format was invalid */ - void setCreatedProperty(String created); + void setCreatedProperty(String created) throws InvalidFormatException; /** * Set the date of creation of the resource. @@ -227,8 +231,10 @@ public interface PackageProperties { /** * Set the date and time of the last printing. + * @throws InvalidFormatException only since POI 5.2.0, used to throw unchecked exception + * IllegalArgumentException if format was invalid */ - void setLastPrintedProperty(String lastPrinted); + void setLastPrintedProperty(String lastPrinted) throws InvalidFormatException; /** * Set the date and time of the last printing. @@ -243,8 +249,10 @@ public interface PackageProperties { /** * Set the date on which the resource was changed. + * @throws InvalidFormatException only since POI 5.2.0, used to throw unchecked exception + * IllegalArgumentException if format was invalid */ - void setModifiedProperty(String modified); + void setModifiedProperty(String modified) throws InvalidFormatException; /** * Set the date on which the resource was changed. diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java index 16e0bd13b7..9a3dc05fda 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java +++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/PackagePropertiesPart.java @@ -427,12 +427,8 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP * @see org.apache.poi.openxml4j.opc.PackageProperties#setCreatedProperty(java.util.Optional) */ @Override - public void setCreatedProperty(String created) { - try { - this.created = parseDateValue(created); - } catch (InvalidFormatException e) { - throw new IllegalArgumentException("Date for created could not be parsed: " + created, e); - } + public void setCreatedProperty(String created) throws InvalidFormatException { + this.created = parseDateValue(created); } /** @@ -548,13 +544,8 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP * @see org.apache.poi.openxml4j.opc.PackageProperties#setLastPrintedProperty(java.util.Optional) */ @Override - public void setLastPrintedProperty(String lastPrinted) { - try { - this.lastPrinted = parseDateValue(lastPrinted); - } catch (InvalidFormatException e) { - throw new IllegalArgumentException("lastPrinted : " - + e.getLocalizedMessage(), e); - } + public void setLastPrintedProperty(String lastPrinted) throws InvalidFormatException { + this.lastPrinted = parseDateValue(lastPrinted); } /** @@ -572,13 +563,8 @@ public final class PackagePropertiesPart extends PackagePart implements PackageP * @see org.apache.poi.openxml4j.opc.PackageProperties#setModifiedProperty(java.util.Optional) */ @Override - public void setModifiedProperty(String modified) { - try { - this.modified = parseDateValue(modified); - } catch (InvalidFormatException e) { - throw new IllegalArgumentException("modified : " - + e.getLocalizedMessage(), e); - } + public void setModifiedProperty(String modified) throws InvalidFormatException { + this.modified = parseDateValue(modified); } /**