问题描述
我的要求是验证给定日期不应该是未来日期。
例如 today date is 01/01/2020
.
输入日期:
30/01/2020
输出:
Date should not be Future date.
解决方法
替代建议
from statsmodels.tsa.arima_model import ARIMA
arima = ARIMA(train['Passengers'],order=(8,1,1))
arima_result = arima.fit()
arima_result.predict(start=train.index[1],end=train.index[-1])
Month
1949-02-01 2.532206
1949-03-01 3.585345
1949-04-01 6.018756
1949-05-01 -2.077600
1949-06-01 -1.577707
...
1959-08-01 -10.896945
1959-09-01 -86.790586
1959-10-01 -49.189211
1959-11-01 -50.916200
1959-12-01 -3.487137
Freq: MS,Length: 131,dtype: float64
,
您也可以使用相等运算符将它们作为日期进行比较。
对于骡子 3:
%dw 1.0
%input payload application/json
%output application/json
%function isFutureDate(dt) (dt as :date) > (now as :date)
%var dt = "30/01/2020" as :date { format: "dd/MM/yyyy" }
---
isFuture: isFutureDate(dt)
对于骡子 4:
%dw 2.0
output application/json
fun isFutureDate(dateToTest: Date | DateTime) =
(dateToTest as Date) > (now() as Date)
var date = |2021-06-10|
---
isFutureDate(date)
,
1.通过#[server.dateTime]
获取当前日期。
2.设置转换消息。
"datevalidation": (payload.DateOfBirth as :date {format:"yyyy-MM-dd"}) < (flowVars.currentdate as :date {format:"yyyy-MM-dd"}
3.添加验证组件isTure
.
<validation:is-true config-ref="Validation_Configuration" expression="#[payload.datevalidation]" doc:name="Validation" message="date should not be Future."/>
完整代码。
<mule xmlns:validation="http://www.mulesoft.org/schema/mule/validation" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/validation http://www.mulesoft.org/schema/mule/validation/current/mule-validation.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<validation:config name="Validation_Configuration" doc:name="Validation Configuration"/>
<flow name="helloFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/hello" allowedMethods="GET" doc:name="HTTP"/>
<set-variable variableName="currentdate" value="#[server.dateTime]" doc:name="current date Variable"/>
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
{
"datevalidation": (payload.DateOfBirth as :date {format:"yyyy-MM-dd"}) < (flowVars.currentdate as :date {format:"yyyy-MM-dd"})
}]]></dw:set-payload>
</dw:transform-message>
<validation:is-true config-ref="Validation_Configuration" expression="#[payload.datevalidation]" doc:name="Validation" message="date should not be Future."/>
<logger level="INFO" doc:name="Logger"/>
</flow>
</mule>
希望对您有所帮助。