0

I have spring batch configuration for spring outbound sftp which has

<property name="remoteDirectory" value="/SFTP/Books_File_20160629"></property>

I want _20160629 to be today's date in same yyyymmdd format rather than hard coding.

Please tell me is there any way for that ?

Thanks,

Aiden

Mofi
  • 46,139
  • 17
  • 80
  • 143
Aiden
  • 460
  • 2
  • 11
  • 29
  • see [here](http://stackoverflow.com/a/18024049/2152082) – Stephan Jun 29 '16 at 10:11
  • This is very confusing. I actually want java spring batch XML way to put today's date in yyyMMdd format but only using XML, don't want to make any java class . e.g. – Aiden Jun 29 '16 at 10:28

1 Answers1

2

Are you looking for something like this

<property name="resources" value="/SFTP/Books_File_*#{currentDate}"/>

Below beans should be added in your context.xml

<bean id="fastDateFormat" class="org.apache.commons.lang.time.FastDateFormat"
    factory-method="getInstance">
    <constructor-arg value="yyyyMMdd" />
</bean>

<bean id="currentDate" class="java.util.Date" factory-bean="fastDateFormat"
    factory-method="format">
    <constructor-arg>
        <bean class="java.util.Date" />
    </constructor-arg>
</bean>
Jay
  • 429
  • 2
  • 8
  • 23