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

Incorrect Date Parsing for mm-dd-yyyy Format, Defaults to Current Date #319

Closed
Bucephalus-lgtm opened this issue Jun 18, 2024 · 5 comments
Closed

Comments

@Bucephalus-lgtm
Copy link

I have an Excel file where I have set a date field in the mm-dd-yyyy format. When I try to parse this file using Poiji.fromExcel(<file_path>, Class<T>) in my Java Spring Boot project, the date field is set with the value of the current date instead of the actual date from the file. I suspect that this issue arises because Poiji uses the default dd/M/yyyy format for date parsing.

Is there a way to make Poiji handle date fields more flexibly? Ideally, as long as the field type is marked as Date, the format of the date should not matter. Can Poiji be configured to recognize and correctly parse various date formats without explicitly specifying each one?

Thank you for your assistance.

Copy link

Thank you for contributing to Poiji! Feel free to create a PR If you want to contribute directly :)

@ozlerhakan
Copy link
Owner

ozlerhakan commented Jun 18, 2024

Hi @Bucephalus-lgtm ,

You can check what format number for the date cell is used with https://github.com/ozlerhakan/poiji?tab=readme-ov-file#debug-cells-formats and once you have the number, you can update it with this step: https://github.com/ozlerhakan/poiji?tab=readme-ov-file#modify-cells-formats.

@Bucephalus-lgtm
Copy link
Author

Hello @ozlerhakan Thanks for the quick response!
I understand that but the twist lies here:
I have the date attribute with LocalDate datatype in my model class. I know, changing the field to String parses dates correctly, indicating an issue with Poiji's default dd/M/yyyy format.

Moreover, I must keep the date fields as LocalDate in my model class because my entity class uses LocalDate, and I need to save the data to a DB. Is there a way to make Poiji flexibly handle various date formats without explicit specification, ensuring correct parsing for LocalDate fields?

Thank you for your assistance.

@ozlerhakan
Copy link
Owner

ozlerhakan commented Jun 22, 2024

Consider using dateFormatter to change the default format in your own PoijiOptions object.

@Bucephalus-lgtm
Copy link
Author

Correct, closing the issue hereby.

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