Excel cell has date format m/d/yyyy
and show date with 4 digits year. However POI returns date in another format m/d/yy
. The cell style returns the same format with 2 digits year cell.getCellStyle().getDataFormatString()
.
Is it possible to get the same format as I see in Excel with POI?
In Excel Cell Style issue I have shown that if a date in
Excel
which is formatted using the default date format (Short Date
) only has the format id0xE
(14) stored in the file and there is not a format pattern stored anywhere. So howShort Date
will be displayed in Excel depends on the locale settings of the system.How working around this issue without using
apache poi
'sDataFormatter
is also shown in that answer.Using
apache poi
'sDataFormatter
we can work around this issue with customizing theDataFormatter
.Example:
Excel:
Code:
Result having
java.util.Locale.GERMANY
set:Result having
java.util.Locale.US
set:Result having
java.util.Locale.UK
set: