Hi Team,
While testing the DurationFormatterUtils functionality, I came across a couple of issues that I'd like to address in this PR
- Empty String Handling in
parseMethod: -
Currently, when an empty string (
""," ") is passed to theparseComposite(value)method, the result isPT0Sinstead of an exception being thrown. This doesn't seem like the correct behavior, as an empty string is an invalid input and returningPT0Scan be misleading in this case. -
NullPointerException (NPE) in
printMethod: - The
printmethod does not handlenullvalues properly for theDurationparameter, resulting in aNullPointerException.
### Changes
+ parse method:
+ Added validation for empty strings and null values.
+ print method:
+ Added validation for null Duration values.
+ Changed error handling to throw Exception instead of Throwable
Thank you for taking the time to review this PR! Please feel free to share any feedback or suggestions.
Comment From: snicoll
@Seungpang thanks for the PR. I've reverted the change on the print method as the current behavior is expected, considering that Duration is flagged as mandatory.