Giter VIP home page Giter VIP logo

Comments (3)

FranzJr avatar FranzJr commented on August 15, 2024

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.

daniftodi avatar daniftodi commented on August 15, 2024

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.

FranzJr avatar FranzJr commented on August 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.