-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
21.0.4
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
Tested on Linux and macOS.
A DESCRIPTION OF THE PROBLEM :
If one uses a date formatter created with:
DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.US);
The formatted date under Java 17 cannot be read with Java 21. One will get a parse exception.
The variable "dBytes" holds different content in Java 17 vs Java 21.
Java 17: {byte[23]@4399} [74, 97, 110, 32, 49, 44, 32, 49, 57, 55, 48, 44, 32, 49, 58, 48, 48, 58, 48, 48, 32, 65, 77]
Java 21: {byte[25]@4728} [74, 97, 110, 32, 49, 44, 32, 49, 57, 55, 48, 44, 32, 49, 58, 48, 48, 58, 48, 48, -30, -128, -81, 65, 77]
Trying to parse the string created in Java 17 in Java 21 will fail.
REGRESSION : Last worked in version 17.0.12
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the reproducer below in JDK 17 and compare it to the output of JDK 21.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The date gets parsed successfully.
ACTUAL -
A ParseException is thrown.
---------- BEGIN SOURCE ----------
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Locale;
public class Main {
public static void main(String[] args) throws ParseException {
var dBytesIn = new byte[] {74, 97, 110, 32, 49, 44, 32, 49, 57, 55, 48, 44, 32, 49, 58, 48, 48, 58, 48, 48, 32, 65, 77};
var dStrIn = new String(dBytesIn, StandardCharsets.UTF_8);
var df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.US);
var d = df.parse(dStrIn); // ParseException will be thrown here
System.out.println(d);
}
}
---------- END SOURCE ----------
FREQUENCY : always
Tested on Linux and macOS.
A DESCRIPTION OF THE PROBLEM :
If one uses a date formatter created with:
DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.US);
The formatted date under Java 17 cannot be read with Java 21. One will get a parse exception.
The variable "dBytes" holds different content in Java 17 vs Java 21.
Java 17: {byte[23]@4399} [74, 97, 110, 32, 49, 44, 32, 49, 57, 55, 48, 44, 32, 49, 58, 48, 48, 58, 48, 48, 32, 65, 77]
Java 21: {byte[25]@4728} [74, 97, 110, 32, 49, 44, 32, 49, 57, 55, 48, 44, 32, 49, 58, 48, 48, 58, 48, 48, -30, -128, -81, 65, 77]
Trying to parse the string created in Java 17 in Java 21 will fail.
REGRESSION : Last worked in version 17.0.12
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the reproducer below in JDK 17 and compare it to the output of JDK 21.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The date gets parsed successfully.
ACTUAL -
A ParseException is thrown.
---------- BEGIN SOURCE ----------
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Locale;
public class Main {
public static void main(String[] args) throws ParseException {
var dBytesIn = new byte[] {74, 97, 110, 32, 49, 44, 32, 49, 57, 55, 48, 44, 32, 49, 58, 48, 48, 58, 48, 48, 32, 65, 77};
var dStrIn = new String(dBytesIn, StandardCharsets.UTF_8);
var df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.US);
var d = df.parse(dStrIn); // ParseException will be thrown here
System.out.println(d);
}
}
---------- END SOURCE ----------
FREQUENCY : always
- relates to
-
JDK-8324665 Loose matching of space separators in the lenient date/time parsing mode
- Resolved