@Test public void invokeParamStringDuration() { FunctionTestUtil.assertResult(durationFunction.invoke("P2D"), Duration.of(2, ChronoUnit.DAYS)); FunctionTestUtil.assertResult(durationFunction.invoke("P2DT3H"), Duration.of(2, ChronoUnit.DAYS).plusHours(3)); FunctionTestUtil.assertResult( durationFunction.invoke("P2DT3H28M"), Duration.of(2, ChronoUnit.DAYS).plusHours(3).plusMinutes(28)); FunctionTestUtil.assertResult( durationFunction.invoke("P2DT3H28M15S"), Duration.of(2, ChronoUnit.DAYS).plusHours(3).plusMinutes(28).plusSeconds(15)); }
public FEELFnResult<TemporalAmount> invoke(@ParameterName( "from" ) String val) { if ( val == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", "cannot be null")); } if ( val.indexOf("-") > 0) { return FEELFnResult.ofError( new InvalidParametersEvent(Severity.ERROR, "from", "negative values for units are not allowed.") ); } try { return FEELFnResult.ofResult( Duration.parse( val ) ); } catch( DateTimeParseException e ) { try { return FEELFnResult.ofResult(ComparablePeriod.parse(val).normalized()); } catch( DateTimeParseException e2 ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", "date-parsing exception", new RuntimeException(new Throwable() { public final List<Throwable> causes = Arrays.asList( new Throwable[]{e, e2} ); } ))); } } }
DurationFunction extends BaseFEELFunction { public FEELFnResult<TemporalAmount> invoke(@ParameterName( "from" ) String val) { if ( val == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", "cannot be null")); } if ( val.indexOf("-") > 0) { return FEELFnResult.ofError( new InvalidParametersEvent(Severity.ERROR, "from", "negative values for units are not allowed.") ); } try { return FEELFnResult.ofResult( Duration.parse( val ) ); } catch( DateTimeParseException e ) { try { return FEELFnResult.ofResult(ComparablePeriod.parse(val).normalized()); } catch( DateTimeParseException e2 ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", "date-parsing exception", new RuntimeException(new Throwable() { public final List<Throwable> causes = Arrays.asList( new Throwable[]{e, e2} ); } ))); } } } }
DurationFunction extends BaseFEELFunction { public FEELFnResult<TemporalAmount> invoke(@ParameterName( "from" ) String val) { if ( val == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", "cannot be null")); } if ( val.indexOf("-") > 0) { return FEELFnResult.ofError( new InvalidParametersEvent(Severity.ERROR, "from", "negative values for units are not allowed.") ); } try { return FEELFnResult.ofResult( Duration.parse( val ) ); } catch( DateTimeParseException e ) { try { return FEELFnResult.ofResult(ComparablePeriod.parse(val).normalized()); } catch( DateTimeParseException e2 ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", "date-parsing exception", new RuntimeException(new Throwable() { public final List<Throwable> causes = Arrays.asList( new Throwable[]{e, e2} ); } ))); } } } DurationFunction(); }
DurationFunction extends BaseFEELFunction { public FEELFnResult<TemporalAmount> invoke(@ParameterName( "from" ) String val) { if ( val == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", "cannot be null")); } if ( val.indexOf("-") > 0) { return FEELFnResult.ofError( new InvalidParametersEvent(Severity.ERROR, "from", "negative values for units are not allowed.") ); } try { return FEELFnResult.ofResult( Duration.parse( val ) ); } catch( DateTimeParseException e ) { try { return FEELFnResult.ofResult(ComparablePeriod.parse(val).normalized()); } catch( DateTimeParseException e2 ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", "date-parsing exception", new RuntimeException(new Throwable() { public final List<Throwable> causes = Arrays.asList( new Throwable[]{e, e2} ); } ))); } } } DurationFunction(); FEELFnResult<TemporalAmount> invoke(@ParameterName( "from" ) String val); FEELFnResult<TemporalAmount> invoke(@ParameterName( "from" ) TemporalAmount val); }
DurationFunction extends BaseFEELFunction { public FEELFnResult<TemporalAmount> invoke(@ParameterName( "from" ) String val) { if ( val == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", "cannot be null")); } if ( val.indexOf("-") > 0) { return FEELFnResult.ofError( new InvalidParametersEvent(Severity.ERROR, "from", "negative values for units are not allowed.") ); } try { return FEELFnResult.ofResult( Duration.parse( val ) ); } catch( DateTimeParseException e ) { try { return FEELFnResult.ofResult(ComparablePeriod.parse(val).normalized()); } catch( DateTimeParseException e2 ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", "date-parsing exception", new RuntimeException(new Throwable() { public final List<Throwable> causes = Arrays.asList( new Throwable[]{e, e2} ); } ))); } } } DurationFunction(); FEELFnResult<TemporalAmount> invoke(@ParameterName( "from" ) String val); FEELFnResult<TemporalAmount> invoke(@ParameterName( "from" ) TemporalAmount val);  }