I am implementing integration with external service which requires current date and time. The documentation of the service says that it accepts the datetime in ISO 8601 format, but that's only partially true – it doesn't support timezone offset.
When I try ${date:now:yyyy-MM-dd'T'HH:mm:ssZ}
in Camel, I get 2017-08-16T21:45:10+0200
, which is not acceptable by the service.
Is there a way to make Camel date format output current date in UTC? I would like to get 2017-08-16T19:45:10Z
instead of 2017-08-16T21:45:10+0200
.
I would like to avoid writing separate bean for that, so I prefer solution implemented purely in XML DSL.
I've managed to come up with a solution using Groovy expression:
<groovy>
java.time.ZonedDateTime.now(java.time.ZoneOffset.UTC)
.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssX"))
</groovy>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With