I am unable to parse a German date (dd.MM.yyyy
) from an excel sheet using Poi. In fact, reading the date cell returns a (d/M/yyyy
) pattern String date, although the excel cell format is (Date dd.MM.yyyy
) as it is shown in the following screenshot:
Source code :
DataFormatter formatter = new DataFormatter();
SimpleDateFormat dateFormatter = new SimpleDateFormat("dd.MM.yyyy");
String dateString = formatter.formatCellValue(row.getCell(11)).trim();//date="1/3/2018"
Date dateStart = dateFormatter.parse(dateString);//throws a java.text.ParseException
P.S : A simple solution to circumvent this problem would be using a SimpleDateFormat("d/M/yyyy")
but I would like to fix this problem and understand the reason behind this unexpected behavior.