Spring Expression Language adding timestamp

815 views Asked by At

My program pulls articles from API using HTTP requests. To see which articles were pulled already from the API, a timestamp is used. Now my problem is, my program should only pull articles within 3 days timeframe. And not more. i.e. It should not exceed the current timestamp. That means, like if the current time is Wednesday 14:00, then the articles from Monday, Tuesday until now(Wednesday 14:00) should be pulled. The first chain here receives the last timestamp file, My code is:

<int:channel id="timestampFile" />

    <int:chain input-channel="timestampFile" output-channel="timestampWithHeaders">
            <file:file-to-string-transformer delete-files="false" charset="UTF-8" />
        <int:header-enricher >
            <int:header name="beginTime" expression="payload" />
            <int:header name="endTime" expression="new Long(payload) + new Long(${abc.poll.frequency})" />
            <int:header name="offset" value="0"/>
        </int:header-enricher>
    </int:chain>

How can I check if the end time is 3 days from the begin time and should not exceed the current timestamp?

1

There are 1 answers

6
Gary Russell On

You can simply compare the long values:

endTime < beginTime + 60000*60*24*3