-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
has-failing-testIndicates that there exists a test case (under `failing/`) to reproduce the issueIndicates that there exists a test case (under `failing/`) to reproduce the issue
Milestone
Description
Search before asking
- I searched in the issues and found nothing similar.
Describe the bug
As already addressed in #2167 Jackson adds a leading “+” for ISO-8601 dates (expanded representation) when the year value is greater than 9999, and “–” for BCE dates, during serialization.
However, deserialization of these ISO-8601 dates does not work in reverse.
Version Information
2.19.2
Reproduction
import com.fasterxml.jackson.databind.util.StdDateFormat;
import java.text.ParseException;
import java.util.Date;
class StdDateFormatTest {
public static void main(String[] args) throws ParseException {
StdDateFormat formatter = new StdDateFormat();
Date dateFuture = new Date(Long.MAX_VALUE);
Date datePast = new Date(Long.MIN_VALUE);
//this part works fine
String dateFutureAsString = formatter.format(dateFuture);
String datePastAsString = formatter.format(datePast);
// The test fails because parsing back throws ParseException
Date parsedBackDateFuture = formatter.parse(dateFutureAsString);
Date parsedBackDatePast = formatter.parse(datePastAsString);
assert parsedBackDateFuture.getTime() == dateFuture.getTime();
assert parsedBackDatePast.getTime() == datePast.getTime();
}
}Expected behavior
All formatted dates are being parsed back correctly.
Additional context
Location:
| && Character.isDigit(dateStr.charAt(0)) |
Metadata
Metadata
Assignees
Labels
has-failing-testIndicates that there exists a test case (under `failing/`) to reproduce the issueIndicates that there exists a test case (under `failing/`) to reproduce the issue