Comments (9)
Thanks @vaquarkhan , Now I see that there is a style in these columns and poi by itself gets their format index as 14 and theirs format string as 'm/d/yy'. You can debug all the cells of an excel file via https://github.com/ozlerhakan/poiji#debug-cells-formats.
What you need to do is you can convert the format string of the format index via https://github.com/ozlerhakan/poiji#modify-cells-formats.
You can use these steps:
PoijiNumberFormat numberFormat = new PoijiNumberFormat();
numberFormat.putNumberFormat((short) 14, "dd/mm/yyyy");
PoijiOptions options = PoijiOptions.PoijiOptionsBuilder.settings()
.poijiNumberFormat(numberFormat)
.build();
and here it is:
BTW when I opened it up on my local the columns look like this:
from poiji.
Let me understand clearly, you have a date column and you map it as String as follows:
@ExcelCellName("COLUMN_DATE")
String date;
and you get the value as "3/30/21" right?
Normally It shouldn't be this way since it's of type String. Could you give me examples?
from poiji.
Now here is my POJO
@ExcelCell(21)
String startDate;
@ExcelCell(22)
String endDate;
Service code :
List resource = Poiji.fromExcel(new File(SAMPLE_XLSX_FILE_PATH), Resource.class);
When i am debugging found inside list value is change once read by Poiji ,its working fine with POI api
Once list populated i am sending into Springboot Repository and inside calling JDBC template to insert records
So when going to insert i am converting this String date to Java.sql.date and insert.
SInce Poiji reading 3/30/21 conversion adding wrong values into db
Following method is my conversion method
private static java.sql.Date stringToDate(String str){
if (null==str) return null;
if (str.isBlank()||str.isEmpty()) return null;
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy");//yyyyMMdd
Date parsed = null;
try {
parsed = format.parse(str);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new java.sql.Date(parsed.getTime());
}
public static void main (String args[]) {
String str="3/30/2021";
java.sql.Date date=stringToDate( str);
System.out.println(date);
}
from poiji.
Could you please share with me an excel file with those few examples?
from poiji.
from poiji.
I need your sample excel file @vaquarkhan , otherwise I tried but couldn't produce this case for the date values like '3/30/2021'
from poiji.
sample.xlsx
here you go
from poiji.
Thanks let me check
from poiji.
you can use 3.1.3 of Poiji @vaquarkhan , thank you for your contribution :)
from poiji.
Related Issues (20)
- Cannot get a STRING value from a NUMERIC cell HOT 1
- Potential IAE with 4.1.1 due to deprecation fix HOT 3
- data not getting mapped for xlsx file to pojo object HOT 2
- Blanks in Excel cells are always parsed into null values when .preferNullOverDefault(true) is used HOT 2
- Reading Excel With japanese character, that include phonetic text HOT 5
- Year Issue HOT 13
- com.poiji.exception.PoijiInstantiationException: Cannot create a new instance of aadhar.StudentInfo HOT 2
- When I set up headerCount with 0, @ExcelUnknownCells does not parse correctly HOT 5
- How can I ignore external workbook references in formula HOT 18
- How can I get correct date time from sheet HOT 7
- Hi can u help for the attached excel is it possible to convert it as pojo ? HOT 2
- Error "FATAL XMLHelper : -1: -1: Premature end of file" when parsing a file. HOT 5
- Empty row on parsing. HOT 3
- Regex Expression support for column name(s) HOT 1
- Expose details of PoijiRowSpecificException HOT 6
- Improve mandatoryCell behavior for opened sheets HOT 12
- Unable to Retrieve the values from excel sheet properly HOT 3
- Vulnerabilities on Transitive Dependencies in Commons Compress 1.25 HOT 4
- issue with parsing to String value that is Double or BigInteger HOT 6
- Incorrect Date Parsing for mm-dd-yyyy Format, Defaults to Current Date HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from poiji.