如何在Camel XML中为Exchange Header设置纽约时区的昨日日期时间?
Solution to Set 24-Hour Prior Date/Time in Camel Exchange Header
Got it, let's tweak your Camel XML code to set the date/time 24 hours before the current time (still using New York's GMT-5 timezone) into the order_creation_date header.
Here's the modified working code:
<setHeader headerName="order_creation_date"> <simple resultType="java.lang.String"> ${date-with-timezone:now.minus(24, "hours"):GMT-5:MM-dd-yyyy HH:mm:ss} </simple> </setHeader>
Quick Breakdown of the Change:
- The core adjustment is swapping
nowwithnow.minus(24, "hours")— this uses Camel Simple language's built-in date arithmetic to subtract a full 24-hour interval from the current moment. - We retain your original timezone (
GMT-5) and date format (MM-dd-yyyy HH:mm:ss) so the output structure stays consistent with your initial setup.
This will populate the order_creation_date header with the exact datetime that occurred 24 hours prior to the current time, properly formatted for the New York timezone.
内容的提问来源于stack exchange,提问作者Shubham Mehta
相关产品推荐
相关产品推荐

