Comments (3)
I use this to know if the date is fine also i can get the date value whit org.apache.poi.ss.usermodel.DateUtil Library from POI, DOC (https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/DateUtil.html)
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
if (DateUtil.isCellDateFormatted(cell)) {
return true;
}
}
If you just want to get the Date value you can get from the Integer you get http://stackoverflow.com/questions/10477714/converting-integer-time-stamp-into-java-date
from sjxlsx.
Thank you for your response. Integer that I'm getting is not a time stamp, is something around 3000. I think is not related with the data that I have in excel cells.
I don't have in sjxlxs a method getCellType().
from sjxlsx.
Yes because i mix poi advantages whit speed of sjxlxs but i share whit you how you get the value for the integer you get from sjxlxs native.
Also continue using org.apache.poi.ss.usermodel.DateUtil library.
String/Integer value = cell.getCellValue(columnNumber);
try {
Date date = DateUtil.getJavaDate(Double.valueOf(value), TimeZone.getDefault());
DateFormat dateFormat = DateFormat.getDateInstance();
dateFormat.format(date).toString()
return true;
} catch (Exception e) {
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd (HH:mm:ss)", Locale.getDefault());
simpleDateFormat.setLenient(false);
simpleDateFormat.parse(value);
return true;
} catch (Exception ex) {
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault());
simpleDateFormat.setLenient(false);
simpleDateFormat.parse(value);
return true;
} catch (Exception ex1) {
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd (HH:mm:ss)", Locale.getDefault());
simpleDateFormat.setLenient(false);
simpleDateFormat.parse(value);
return true;
} catch (Exception ex2) {
showError("It is not a date, " + columnNumber + " must to be a date");
return false;
}
}
}
}
Please try and let me know if works for you.
from sjxlsx.
Related Issues (14)
- Support getting sheet name HOT 1
- Sheet index - XLSX
- Reading hidden columns and rows?
- Only reading first 52 columns with SheetRowReader.readRow() method HOT 2
- Merge / Combine Cell
- How to write number cell using xlsx workbook
- How support Name manager
- Failed to read xlsx file export from Google drive HOT 2
- Apologies, not an issue with the code itself. I'd just like to know how to use it. HOT 6
- XMLStreamException: Stream encoding error HOT 1
- Streaming without going through a file? HOT 1
- We found a problem with some content in $filename. Do you want us to try and HOT 1
- Example how to create a hyperlink to a web page
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 sjxlsx.