Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

I need a code which should get Date from Excel as YYYY-MM-DD.

It is displaying the date as 31-Dec-2050 which was originally saved in a sheet as 2050-12-31 Format.

System.out.println("<" + sheet.getRow(i).getCell(24) + ">");

should get Date from Excel as YYYY-MM-DD.

1 Answer

0 votes
by (62.9k points)

Import the following libraries:

import java.time.LocalDate;

import java.time.format.DateTimeFormatter;

Then in your class, execute the following functions:

String cv = sheet.getRow(i).getCell(24).getStringCellValue();

DateTimeFormatter dt = DateTimeFormatter.ofPattern( "uuuu-MM-dd");

System.out.println("<" + LocalDate.parse(cv).format(dt) + ">");

Related questions

0 votes
1 answer
asked Jan 28, 2021 in Java by dante07 (13.1k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Dec 4, 2020 in SQL by Appu (6.1k points)

Browse Categories

...