Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Year Issue #292

Closed
vandanagoel opened this issue Sep 20, 2023 · 13 comments
Closed

Year Issue #292

vandanagoel opened this issue Sep 20, 2023 · 13 comments

Comments

@vandanagoel
Copy link

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.

@ozlerhakan
Copy link
Owner

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");

@vandanagoel
Copy link
Author

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

@ozlerhakan
Copy link
Owner

ozlerhakan commented Sep 25, 2023

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?

@vandanagoel
Copy link
Author

I am using poiji 3.10. Whats the highest evel of Poiji I can use on JDK 8?
abc - Copy.xlsx

@ozlerhakan
Copy link
Owner

3.1.7 should be compatible with Java 8.

@vandanagoel
Copy link
Author

That one is. Thats what I am using. Is 4.1.1 compatible with Java 8?

Seems like issue might be with 3.17

@ozlerhakan
Copy link
Owner

No, it works with Java 11.

@vandanagoel
Copy link
Author

So is there any fix for 3.1.7 for year issue?

@ozlerhakan
Copy link
Owner

I'll look into your case with the release supporting Java 8.

@vandanagoel
Copy link
Author

Thank you so much for your help

@ozlerhakan
Copy link
Owner

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");

@vandanagoel
Copy link
Author

That does it. Thank you so much.

@ozlerhakan
Copy link
Owner

Great! No problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants