java - apache poi language version causes date format misinterpretation -


edit: avoid confusions, here's (again) improved version of original question:

question how can read out string representation of cell way microsoft excel display it, without knowing respective hard-coding formatting-settings (but example using cell's own formatting settings format output).

answer far no problem if using us-version of excel, other versions apache poi return strings equivalent how us-version of excel display , there no built-in way in apache poi change this. way can confirm "working" - gagravarr suggested - switch language on mac us/en. apache poi , excel deliver same result. kind of inverse solution.

the problem is: cell displayed 01.12.13 in german version of excel, since it's formatted date

hssfcell cell = (hssfcell) celliter.next(); hssfdataformatter formatter=new hssfdataformatter(); string val=formatter.formatcellvalue(cell) 

gives me val of 21/01/13.


the original question was:

i having xlsx file containing date fields displayed in excel like

01.12.13 using format setting of cell tt.mm.jj

if read same file apache poi, getting cell , format à la

hssfcell cell = (hssfcell) celliter.next(); hssfdataformatter formatter=new hssfdataformatter(); string val=formatter.formatcellvalue(cell) 

(with celliter being valid iterator of course, simplified example)

my val turns out 21/01/13. understand hsfdataformatter's method formatcellvalue() should return string of value formatted cell's format setting.

does know how can val contain same format in excel?

i appreciate help! thank you!

you can customize date format following:

hssfcell cell = (hssfcell) celliter.next(); simpledateformat dtformat = new simpledateformat("dd.mm.yy"); date date=cell.getdatecellvalue(); system.out.println(dtformat.format(date).tostring()); 

this print value 21.01.13.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -