I want to convert Date to String in different formats, but i am getting the below error,
DateTimeException-Field DayOfYear cannot be printed as the value 234 exceeds the maximum print width of 2
Below are the different formats,
"MMDDYY"
"DD_MM_YY"
"YYYYMMDD"
"MMDD"
"DD-MM-YY"
Below is my code,
LocalDate localDate = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("DD-MM-YY");
String formattToString = localDate.format(formatter);
Am i missing something here ?