I have defined a global function as below
<configuration doc:name="Configuration">
<expression-language autoResolveVariables="true">
<import class="java.text.SimpleDateFormat" />
<global-functions>
def convertDate(shiftDate){
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return dateFormat.format(shiftDate);
}
</global-functions>
</expression-language>
</configuration>
But when calling via logger nothing seems to happen
<logger message="Convert Date #[convertDate(xpath://address/@timestamp)]" level="DEBUG" doc:name="Logger"/>
The xpath expression xpath://address/@timestamp yields 2014-10-29T15:23:07
But before the logger I see
xpath-branch:/address/@timestamp is: org.dom4j.tree.DefaultAttribute@6452310a [Attribute: name timestamp value "2014-10-29T15:23:07"]
The error message is as below
org.mule.api.expression.InvalidExpressionException: [Error: unexpected end of statement]
[Near : {... convertDate(xpath://address/@payloadID) ....}]
What am I doing wrong here? Many Thanks.