Results 1 to 5 of 5

Thread: BeanWrapperFieldExtractor Formatting Fields

  1. #1
    Join Date
    Dec 2009
    Posts
    20

    Default BeanWrapperFieldExtractor Formatting Fields

    Hi,

    I have the following FlatFileItemWriter:

    Code:
    	<bean id="accountFlatFileItemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter">
    		<property name="resource" value="c:\test.csv" />
    		<property name="lineAggregator">
    			<bean
    				class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
    				<property name="delimiter" value="," />
    				<property name="fieldExtractor">
    					<bean
    						class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
    						<property name="names" value="id,lastName,firstName,dateModified" />
    					</bean>
    				</property>
    			</bean>
    		</property>
    	</bean>
    This will create an csv with the following columns:
    id,lastName,firstName,dateModified

    I am new to Spring Batch project and wanted to know how would I go abouts formatting the "dateModified" values? i.e.: dd/MM/yyyy...?

    Appreciate any feedback.

  2. #2
    Join Date
    Jun 2005
    Posts
    4,241

    Default

    Use a FormatterLineAggregator is one way, or write your own aggregator.

  3. #3
    Join Date
    Dec 2009
    Posts
    20

    Default

    Yeah but what I what to know how... do you have a sample code or links?

  4. #4
    Join Date
    Jun 2005
    Posts
    4,241

    Default

    There is a sample that uses the FormatterLineAggregator (https://fisheye.springsource.org/bro...ngth.xml#r2746). For more on formats see the JDK (http://java.sun.com/j2se/1.5.0/docs/...Formatter.html).

  5. #5
    Join Date
    Dec 2009
    Posts
    20

    Default

    Thanks Dave.

Posting Permissions

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