0

I currently have the below code utilized for retrieving current date in spring batch. Is there a way to implement a similar solution, but instead, returning the previous business day instead of the currentDate?

<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>
Ay123
  • 55
  • 7
  • Before digging into how to technically do this, why would you need to create a bean of type `Date` with the current date (or previous day date)? This should be a runtime information and not a static bean definition. What are you trying to achieve? – Mahmoud Ben Hassine Oct 21 '22 at 07:46

1 Answers1

0

Using natty you can parse natural language date expressions like "yesterday" or "24 hours before now" to generate a java.util.Date object.

httPants
  • 1,832
  • 1
  • 11
  • 13