refactor date parsing to use ISO_DATE_TIME#132
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors date parsing in the CarbonReductorVariableMapper to use Java's built-in ISO_DATE_TIME formatter instead of a custom date pattern. The change simplifies the code and provides more flexibility in accepting ISO 8601 date-time formats with variable millisecond precision.
Changes:
- Replaced custom date pattern
yyyy-MM-dd'T'HH:mm:ss.SSSX'['z']'with standardISO_DATE_TIMEformatter - Simplified error message to remove specific format details
- Added parameterized test to verify parsing of ISO date-time strings with varying millisecond precision
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| CarbonReductorVariableMapper.java | Replaced custom date pattern with ISO_DATE_TIME formatter and simplified error message |
| CarbonReductorVariableMapperTest.java | Added parameterized test for variable-precision ISO date-time formats and updated error message assertion |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| DATE_TIME_PATTERN.replace("'", "") | ||
| ) | ||
| ); | ||
| throw new IllegalArgumentException("Milestone: Unknown date time format"); |
There was a problem hiding this comment.
The error message has been made less helpful by removing the expected format. While the old message included the specific expected format pattern, the new message provides no guidance to users on what format is expected. Consider adding information about the expected ISO 8601 format or providing an example in the error message to help users correct their input.
| throw new IllegalArgumentException("Milestone: Unknown date time format"); | |
| throw new IllegalArgumentException("Milestone: Unknown date time format. Expected ISO 8601, e.g. '2024-01-31T13:45:00Z'."); |
lwluc
left a comment
There was a problem hiding this comment.
Copilot findings are useful and should be resolved
215d597 to
5b4d411
Compare
5b4d411 to
c1f5c34
Compare
No description provided.