use of java.time.DateTimeException in project drools by kiegroup.
the class HourDiffFunction method invoke.
public FEELFnResult<BigDecimal> invoke(@ParameterName("datetime1") String datetime1, @ParameterName("datetime2") String datetime2) {
if (datetime1 == null) {
return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "datetime1", "cannot be null"));
}
if (datetime2 == null) {
return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "datetime2", "cannot be null"));
}
try {
TemporalAccessor dt1 = BuiltInFunctions.getFunction(DateAndTimeFunction.class).invoke(datetime1).cata(BuiltInType.justNull(), Function.identity());
TemporalAccessor dt2 = BuiltInFunctions.getFunction(DateAndTimeFunction.class).invoke(datetime2).cata(BuiltInType.justNull(), Function.identity());
return invoke(dt1, dt2);
} catch (DateTimeException e) {
return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "datetime", "invalid 'date' or 'date and time' parameter", e));
}
}
use of java.time.DateTimeException in project drools by kiegroup.
the class MinutesDiffFunction method invoke.
public FEELFnResult<BigDecimal> invoke(@ParameterName("datetime1") String datetime1, @ParameterName("datetime2") String datetime2) {
if (datetime1 == null) {
return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "datetime1", "cannot be null"));
}
if (datetime2 == null) {
return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "datetime2", "cannot be null"));
}
try {
TemporalAccessor dt1 = BuiltInFunctions.getFunction(DateAndTimeFunction.class).invoke(datetime1).cata(BuiltInType.justNull(), Function.identity());
TemporalAccessor dt2 = BuiltInFunctions.getFunction(DateAndTimeFunction.class).invoke(datetime2).cata(BuiltInType.justNull(), Function.identity());
return invoke(dt1, dt2);
} catch (DateTimeException e) {
return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "datetime", "invalid 'date' or 'date and time' parameter", e));
}
}
use of java.time.DateTimeException in project drools by kiegroup.
the class MonthDiffFunction method invoke.
public FEELFnResult<BigDecimal> invoke(@ParameterName("datetime1") String datetime1, @ParameterName("datetime2") String datetime2) {
if (datetime1 == null) {
return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "datetime1", "cannot be null"));
}
if (datetime2 == null) {
return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "datetime2", "cannot be null"));
}
try {
TemporalAccessor dt1 = BuiltInFunctions.getFunction(DateAndTimeFunction.class).invoke(datetime1).cata(BuiltInType.justNull(), Function.identity());
TemporalAccessor dt2 = BuiltInFunctions.getFunction(DateAndTimeFunction.class).invoke(datetime2).cata(BuiltInType.justNull(), Function.identity());
return invoke(dt1, dt2);
} catch (DateTimeException e) {
return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "datetime", "invalid 'date' or 'date and time' parameter", e));
}
}
Aggregations