2 Replies Latest reply on Feb 24, 2017 12:33 PM by cfang

    Format CSV column with date

    richardmoore

      I am using the Jackson CSV writer and am not seeing a way to write out a date as a formatted string. Is there a way to do that or an example you can point me to? What if I have two different date formats?

        • 1. Re: Format CSV column with date
          cfang

          in your POJO, you can apply different date format to different fields.  for ex:

           

          jsr352/StockTrade2.java at master · jberet/jsr352 · GitHub

           

          With that I can have date like:

           

          Date,Time,Open,High,Low,Close,Volume

          01/02/1998,09:30,104.44,104.44,104.44,104.44,67040.0

          01/02/1998,09:31,104.31,104.44,104.31,104.31,10810.0

          01/02/1998,09:32,104.37,104.44,104.31,104.44,13310.0

           

          And the date field can be formated differently, like:

           

          Date,Time,Open,High,Low,Close,Volume

          Fri Jan 02 00:00:00 EST 1998,09:30,104.44,104.44,104.44,104.44,67040.0

          Fri Jan 02 00:00:00 EST 1998,09:31,104.31,104.44,104.31,104.31,10810.0

          Fri Jan 02 00:00:00 EST 1998,09:32,104.37,104.44,104.31,104.44,13310.0

          • 2. Re: Format CSV column with date
            cfang

            BTW, if you are using the other JBeret csvItemWriter (the one that's based on super-csv), you can configure cellProcessors batch property for formating each column.