Get and format yesterday's date in Camel's expression language

Viewed 15490

I am using the date in a path in Camel:

fileName=${date:now:dd-MM-yyyy}

but what I need is now - 1 day. Is that possible?

4 Answers

Camel Simple language date variable supports command with offset:

Supported commands are: now for current timestamp, [...] Command accepts offsets such as: now-24h or header.xxx+1h or even now+1h30m-100.

So you can write your assigment as:

fileName=${date:now-1d:dd-MM-yyyy}

Note that -1d equals to -24h even not mentioned in the documentation.

Related