0 votes
1 view
in Devops and Agile by (19.8k 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 (63.4k 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
0 votes
1 answer
0 votes
1 answer
asked 1 day ago in SQL by Appu (1.5k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...