Reputation: 1154
I am using Apache POI to read Excel file(.xlsx) and validate its contents. We are having a date field in excel whcih should be in format MM/dd/yyyy.
Suppose if the date fild has two values as follows,
1) 04/24/2014 2) 04242014
I have to accept the first one and reject the second. Since excel stores both these values in integer format, I am not able to differentiate them. Please suggest if you have any idea about how to solve this.
Upvotes: 0
Views: 4177
Reputation: 1144
Apache POI allows to check data format of the cell with:
System.out.println(HSSFDateUtil.isCellDateFormatted(cell));
System.out.println(cell.getCellStyle().getDataFormatString());
which gives for your first cell:
true
DD\/MM\/YYYY
and for second:
true
DDMMYYYY
Upvotes: 1