Hi -
It would be useful if printing a Java Date or Calendar to a CSVFormat.EXCEL
CSVPrinter would generate output that Excel recognises as a date-and-time.
For example the following
PrintWriter outputWriter = new PrintWriter(new
FileOutputStream("output.csv"));
CSVPrinter printer = new CSVPrinter(outputWriter, CSVFormat.EXCEL);
printer.print(new Date());
printer.println();
printer.close();
outputs the raw Date.toString()
Tue Apr 22 12:06:42 BST 2014
which Excel only treats as a string. (It will recognise e.g. yyyy/mm/dd as a
date but I wouldn't know where to look for a definitive set of formats it
will consume.) Ditto probably printing Calendar.getInstance(), or the new
Java 8 LocalDate etc. classes.
One argument against though is then the library perhaps ought to do the
reverse, i.e. spot that it has been passed a date in and construct a Date
class for the value at parse time which may be expensive and often
unnecessary.
Thanks for your consideration. Happy to raise a JIRA 'Wish' ticket if this
seems reasonable.
Rupert.