Results 1 to 2 of 2

Thread: Calendar format in ItemWriter

  1. #1
    Join Date
    Mar 2011
    Posts
    1

    Default Calendar format in ItemWriter

    I'm using a FlatFileItemWriter to write data to a CSV file. Is there any way to register a CustomEditorConfigurer with something in the writer configuration (the LineAggregator or FieldExtractor?) so that I have control over the output format of Calendar/Date properties of the objects being written?

    I'm looking for the ItemWriter analog to the way you register PropertyEditors with a FieldSetMapper during a read.

    Thanks.

  2. #2
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    366

    Default

    To my knowledge there is not a way to register custom formatters for a given property while using the FlatFileItemWriter and the LineAggregators provided by the framework. This leaves you two options:
    1. Implement your own FieldExtractor - This would allow you to format the extracted fields in to the desired String for output by the DelimitedLineAggregator.
    2. Use the FormatterLineAggregator - Since the FormatterLineAggregator uses String.format to generate an output line you can use it to generate your CSV with whatever formatting you'd want. Using this option you would use the format string to determine what each value between the commas would be.

    IMHO, I'd go with the FormatterLineAggregator so I didn't have to write any more code.
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •