I am trying to parse the dd-MMM-yyyy format date.
package com.company; import javax.swing.text.DateFormatter; import java.time.format.DateTimeFormatter; import java.time.*; import java.util.Locale; public class Main { public static void main(String[] args) {
Throws the following exception
java.time.format.DateTimeParseException: Text '12-jan-1900' could not be parsed at index 3 at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949) at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851) at java.time.LocalDate.parse(LocalDate.java:400) at com.company.Main.main(Main.java:20) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
It is well versed in the dd-MM-yyyy format, but does not match the dd-MMM-yyyy format. I was also tired of installing Locale.US , but in this case it also failed.
q126y source share