I have seen the link apache poi DataFormatter on cell containing date solution updated for
"dd/MM/yyyy" format using SimpleDateFormat DtFormat = new SimpleDateFormat("dd/MM/yyyy");
In my case i'm not aware of the format..it may be in any date format. In this case how can I handle?
I have tried to read the date value from the date cell in the xlsx file.
cell having data as: 8/5/2016
output im getting is : 8/5/16
I need the same format as mentioned in that date cell.
if know the format I can use SimpleDateFormat DtFormat = new SimpleDateFormat("dd/MM/yyyy")
. without knowing the format is there any way to get it?
Sample code:
int r1c1=5;
switch (cell.getCellType())
{
case XSSFCell.CELL_TYPE_NUMERIC:
if (HSSFDateUtil.isCellDateFormatted(cell)){
DataFormatter formatter = new DataFormatter();
//Value variable displaying output as 8/5/16 instead of 8/5/2016
value = formatter.formatCellValue(cell);
Hm.put(r1c1, value); //using hashmap to store value
}
break;
}