how to read date cell value in excel using java

Solutions on MaxInterview for how to read date cell value in excel using java by the best coders in the world

showing results for - "how to read date cell value in excel using java"
Jana
12 Sep 2016
1XSSFWorkbook workbook = new XSSFWorkbook(new File(result));
2    XSSFSheet sheet = workbook.getSheetAt(0);
3
4    // Iterate through each rows one by one
5    Iterator<Row> rowIterator = sheet.iterator();
6    while (rowIterator.hasNext()) {
7        Row row = rowIterator.next();
8        // For each row, iterate through all the columns
9        Iterator<Cell> cellIterator = row.cellIterator();
10
11        while (cellIterator.hasNext()) {
12            Cell cell = cellIterator.next();
13            switch (cell.getCellType()) {
14            case Cell.CELL_TYPE_NUMERIC:
15                if (cell.getNumericCellValue() != 0) {
16                    //Get date
17                    Date date = row.getCell(0).getDateCellValue();
18
19
20
21                    //Get datetime
22                    cell.getDateCellValue()
23
24
25                    System.out.println(date.getTime());
26                }
27                break;
28            }
29        }
30    }
Gustavo
24 Jul 2016
112/8/20201
24/6/2021
3