Year Issue
vandanagoel opened this issue · comments
I am reading date from excel in format - d/m/yyyy. For example 10/16/1918
But when I read in Java it comes back as 10/16/18 and using dateformatting it gets converted to 10/16/2018.
I have tried various options but in all cases only "YY" part is read. Below are few things I have tried. In java pojo - date is deined as string
@ExcelCell(6)
private String dob;
PoijiNumberFormat numberFormat = new PoijiNumberFormat();
numberFormat.putNumberFormat((short) 47, "dd/M/yyyy");
OR
PoijiOptions options = PoijiOptions.PoijiOptionsBuilder.settings().datePattern("M/d/yyyy").build();
Any help will very much appreciated.
Could you give a try the following statements for PoijiNumberFormat:
PoijiNumberFormat numberFormat = new PoijiNumberFormat();
numberFormat.putNumberFormat((short) 47, "dd/M/yyyy");
numberFormat.putNumberFormat((short) 22, "dd/M/yyyy");
I am using Java8, com.github.ozlerhakan', name: 'poiji', version: '3.1.0', and 'org.apache.poi', name: 'poi', version: '5.1.0'
Using PoijiNumberFormat numberFormat - actually gives me wrong date. Instead of 10/16/1918 - I get 9/15/18
datePattern(format).dateTimeFormatter(ISO_DATE_TIME) - gives me correct date - but 19 is missing from the year. I am getting 10/16/18 instead of 10/16/1918
Interesting.. It seems to be fixed with the suggestion above in the latest Poiji - v4.1.1 on my laptop. Could you share your excel if It's possible?
I am using poiji 3.10. Whats the highest evel of Poiji I can use on JDK 8?
abc - Copy.xlsx
3.1.7 should be compatible with Java 8.
That one is. Thats what I am using. Is 4.1.1 compatible with Java 8?
Seems like issue might be with 3.17
No, it works with Java 11.
So is there any fix for 3.1.7 for year issue?
I'll look into your case with the release supporting Java 8.
Thank you so much for your help
It seems we're trying to manipulate the wrong index from the internal list. Could you try out the following statement only:
PoijiNumberFormat numberFormat = new PoijiNumberFormat();
numberFormat.putNumberFormat((short) 14, "dd/mm/yyyy");
That does it. Thank you so much.
Great! No problem!