Java apache poi to read exact date format as mentioned in excel -
this question has answer here:
- how read exact cell content of excel file in apache poi 2 answers
- excell cell style issue 1 answer
i have seen link apache poi dataformatter on cell containing date solution updated "dd/mm/yyyy" format using simpledateformat dtformat = new simpledateformat("dd/mm/yyyy");
in case i'm not aware of format..it may in date format. in case how can handle?
i have tried read date value date cell in xlsx file.
cell having data as: 8/5/2016
output im getting : 8/5/16
i need same format mentioned in date cell.
if know format can use simpledateformat dtformat = new simpledateformat("dd/mm/yyyy")
. without knowing format there way 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 8/5/16 instead of 8/5/2016 value = formatter.formatcellvalue(cell); hm.put(r1c1, value); //using hashmap store value } break; }
Comments
Post a Comment