commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benedikt Ritter <brit...@apache.org>
Subject Re: [CSV] Wish: format-specific date generation
Date Fri, 25 Apr 2014 13:25:24 GMT
Agreed, feel free to raise an improvement ticket.


2014-04-22 14:24 GMT+02:00 Gary Gregory <garydgregory@gmail.com>:

> For 1.0 at least, we do not plan on doing any type conversion. Later,
> perhaps, but the current thought is to leave type conversion to other
> components.
>
> Gary
>
>
> On Tue, Apr 22, 2014 at 7:22 AM, Rupert Wood <me@rupey.net> wrote:
>
> > 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.
> >
> >
> >
> >
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition<
> http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message