I write to a CSV file and use it FlatFileItemWriterfor this. I have a bean with this as my class, and I also have a property for the resource, where I provide the name of the file used to write the item.
Can I add a date and time to a file name?
Right now I'm telling him to write a file called report.csv, instead I want him to write a file called report-7-2-2014-16-03.csv
Here's the XML Config for the author
<bean id="csvWriter" class="org.springframework.batch.item.file.FlatFileItemWriter">
<property name="resource">
<bean class="org.springframework.core.io.FileSystemResource">
<constructor-arg value="${REPORT_FILENAME}" />
</bean>
</property>
<property name="shouldDeleteIfExists" value="true" />
<property name="lineAggregator">
<bean class="com.example.CSVLineAggregator" />
</property>
<property name="headerCallback">
<bean class="com.example.CSVHeaderWriter" >
<constructor-arg value="${REPORT_HEADER}" />
</bean>
</property>
</bean>
source
share