A DESCRIPTION OF THE PROBLEM :
With lenient parsing DateTimeFormatter fails to parse strings it produces itself for a standard pattern in ksh-DE locale.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the source code (see below). Note that if you remove parseLenient() from it, then it works as expected.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
On stdout:
d. MMM. y
1. Jan. 1970
{},ISO resolved to 1970-01-01
ACTUAL -
d. MMM. y
1. Jan. 1970
Exception in thread "main" java.time.format.DateTimeParseException: Text '1. Jan. 1970' could not be parsed at index 7
at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1988)
at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1816)
at test.main(test.java:17)
---------- BEGIN SOURCE ----------
import java.time.*;
import java.time.chrono.*;
import java.time.format.*;
import java.time.temporal.*;
import java.util.*;
public class test
{
public static void main (String[] arguments) throws Exception
{
Locale locale = Locale.forLanguageTag ("ksh-DE");
String pattern = DateTimeFormatterBuilder.getLocalizedDateTimePattern (FormatStyle.MEDIUM, null, Chronology.ofLocale (locale), locale);
DateTimeFormatter formatter = new DateTimeFormatterBuilder ().parseLenient ().appendPattern (pattern).toFormatter (locale);
System.out.println (pattern);
System.out.println (formatter.format (LocalDate.ofEpochDay (0)));
System.out.println (formatter.parse (formatter.format (LocalDate.ofEpochDay (0))));
}
}
---------- END SOURCE ----------
FREQUENCY : always
With lenient parsing DateTimeFormatter fails to parse strings it produces itself for a standard pattern in ksh-DE locale.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the source code (see below). Note that if you remove parseLenient() from it, then it works as expected.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
On stdout:
d. MMM. y
1. Jan. 1970
{},ISO resolved to 1970-01-01
ACTUAL -
d. MMM. y
1. Jan. 1970
Exception in thread "main" java.time.format.DateTimeParseException: Text '1. Jan. 1970' could not be parsed at index 7
at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1988)
at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1816)
at test.main(test.java:17)
---------- BEGIN SOURCE ----------
import java.time.*;
import java.time.chrono.*;
import java.time.format.*;
import java.time.temporal.*;
import java.util.*;
public class test
{
public static void main (String[] arguments) throws Exception
{
Locale locale = Locale.forLanguageTag ("ksh-DE");
String pattern = DateTimeFormatterBuilder.getLocalizedDateTimePattern (FormatStyle.MEDIUM, null, Chronology.ofLocale (locale), locale);
DateTimeFormatter formatter = new DateTimeFormatterBuilder ().parseLenient ().appendPattern (pattern).toFormatter (locale);
System.out.println (pattern);
System.out.println (formatter.format (LocalDate.ofEpochDay (0)));
System.out.println (formatter.parse (formatter.format (LocalDate.ofEpochDay (0))));
}
}
---------- END SOURCE ----------
FREQUENCY : always