Re: [CSV] Wish: format-specific date generation

2014-04-25 Thread Benedikt Ritter
Agreed, feel free to raise an improvement ticket.


2014-04-22 14:24 GMT+02:00 Gary Gregory :

> 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  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. /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: garydgreg...@gmail.com | ggreg...@apache.org
> Java Persistence with Hibernate, Second Edition<
> http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition 
> Spring Batch in Action 
> 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


Re: [CSV] Wish: format-specific date generation

2014-04-22 Thread Gary Gregory
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  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. /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: garydgreg...@gmail.com | ggreg...@apache.org
Java Persistence with Hibernate, Second Edition
JUnit in Action, Second Edition 
Spring Batch in Action 
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory


[CSV] Wish: format-specific date generation

2014-04-22 Thread Rupert Wood
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. /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.