4.3.2. Built-in functions in FEEL
To promote interoperability with other platforms and systems, Friendly Enough Expression Language (FEEL) includes a library of built-in functions. The built-in FEEL functions are implemented in the Drools Decision Model and Notation (DMN) engine so that you can use the functions in your DMN decision services.
The following sections describe each built-in FEEL function, listed in the format NAME( PARAMETERS ). For more information about FEEL functions in DMN, see the OMG Decision Model and Notation specification.
4.3.2.1. Conversion functions リンクのコピーリンクがクリップボードにコピーされました!
The following functions support conversion between values of different types. Some of these functions use specific string formats, such as the following examples:
-
date string: Follows the format defined in the XML Schema Part 2: Datatypes document, such as2020-06-01 time string: Follows one of the following formats:-
Format defined in the XML Schema Part 2: Datatypes document, such as
23:59:00z -
Format for a local time defined by ISO 8601 followed by
@and an IANA Timezone, such as00:01:00@Etc/UTC
-
Format defined in the XML Schema Part 2: Datatypes document, such as
-
date time string: Follows the format of adate stringfollowed byTand atime string, such as2012-12-25T11:00:00Z -
duration string: Follows the format ofdays and time durationandyears and months durationdefined in the XQuery 1.0 and XPath 2.0 Data Model, such asP1Y2M
- date( from ) - using date
Converts
fromto adatevalue.Expand 表4.3 Parameters Parameter Type Format fromstringdate stringExample
date( "2012-12-25" ) - date( "2012-12-24" ) = duration( "P1D" )
- date( from ) - using date and time
Converts
fromto adatevalue and sets time components to null.Expand 表4.4 Parameters Parameter Type fromdate and timeExample
date(date and time( "2012-12-25T11:00:00Z" )) = date( "2012-12-25" )
- date( year, month, day )
Produces a
datefrom the specified year, month, and day values.Expand 表4.5 Parameters Parameter Type yearnumbermonthnumberdaynumberExample
date( 2012, 12, 25 ) = date( "2012-12-25" )
- date and time( date, time )
Produces a
date and timefrom the specified date and ignores any time components and the specified time.Expand 表4.6 Parameters Parameter Type datedateordate and timetimetimeExample
date and time ( "2012-12-24T23:59:00" ) = date and time(date( "2012-12-24" ), time( "23:59:00" ))
- date and time( from )
Produces a
date and timefrom the specified string.Expand 表4.7 Parameters Parameter Type Format fromstringdate time stringExample
date and time( "2012-12-24T23:59:00" ) + duration( "PT1M" ) = date and time( "2012-12-25T00:00:00" )
- time( from )
Produces a
timefrom the specified string.Expand 表4.8 Parameters Parameter Type Format fromstringtime stringExample
time( "23:59:00z" ) + duration( "PT2M" ) = time( "00:01:00@Etc/UTC" )
- time( from )
Produces a
timefrom the specified parameter and ignores any date components.Expand 表4.9 Parameters Parameter Type fromtimeordate and timeExample
time(date and time( "2012-12-25T11:00:00Z" )) = time( "11:00:00Z" )
- time( hour, minute, second, offset? )
Produces a
timefrom the specified hour, minute, and second component values.Expand 表4.10 Parameters Parameter Type hournumberminutenumbersecondnumberoffset(Optional)days and time durationor nullExample
time( "23:59:00z" ) = time(23, 59, 0, duration( "PT0H" ))
- number( from, grouping separator, decimal separator )
Converts
fromto anumberusing the specified separators.Expand 表4.11 Parameters Parameter Type fromstringrepresenting a valid numbergrouping separatorSpace ( ), comma (
,), period (.), or nulldecimal separatorSame types as
grouping separator, but the values cannot matchExample
number( "1 000,0", " ", "," ) = number( "1,000.0", ",", "." )
- string( from )
Provides a string representation of the specified parameter.
Expand 表4.12 Parameters Parameter Type fromNon-null value
Examples
string( 1.1 ) = "1.1" string( null ) = null
- duration( from )
Converts
fromto adays and time durationvalue oryears and months durationvalue.Expand 表4.13 Parameters Parameter Type Format fromstringduration stringExamples
date and time( "2012-12-24T23:59:00" ) - date and time( "2012-12-22T03:45:00" ) = duration( "P2DT20H14M" ) duration( "P2Y2M" ) = duration( "P26M" )
- years and months duration( from, to )
Calculates the
years and months durationbetween the two specified parameters.Expand 表4.14 Parameters Parameter Type fromdateordate and timetodateordate and timeExample
years and months duration( date( "2011-12-22" ), date( "2013-08-24" ) ) = duration( "P1Y8M" )