0

I am exporting my data to excel sheet with date field as one of the columns. e.g. I am exporting data as 28/10/2018 12:32. I am editing the date.

After importing the date, it is giving me the date in number, something like 123342.23424. I have already gone through this, but this is not giving the date format in which I have exported. https://stackoverflow.com/questions/3148535/how-to-read-excel-cell-having-date-with-apache-poi

1 Answers1

0

If you get the raw cell date value from your front end, apache poi provides a util date class:

example:

import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.poi.ss.usermodel.DateUtil;

public class Main {
    public static void main(String[] args) {

        Date d = DateUtil.getJavaDate(42064.625);
        SimpleDateFormat f = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        System.out.println(f.format(d));
    }
}

Output:

01/03/2015 15:00:00
Rcordoval
  • 1,932
  • 2
  • 19
  • 25