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
parse
Method: -
Currently, when an empty string (
""
," "
) is passed to theparseComposite(value)
method, the result isPT0S
instead of an exception being thrown. This doesn't seem like the correct behavior, as an empty string is an invalid input and returningPT0S
can be misleading in this case. -
NullPointerException (NPE) in
print
Method: - The
print
method does not handlenull
values properly for theDuration
parameter, 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.