The formatDate example for custom function

This topic explains the concepts of creating a custom function by using an example. The following steps are covered: how to build a function, called formatDate, that parses a string-based date representation and returns it in an alternate format.

The function syntax is as follows:

formatDate( date, inputFormat [, outputFormat] )
Note: The outputFormat parameter is optional. If it is not entered, the function returns the date in the default format, which is yyyy-MM-dd.

Note the following examples of the function:

formatDate( "05102004", "ddMMyyyy" ) returns the date in the format "2004-10-05."

formatDate( "05/10/04 13:25", "dd/MM/yy HH:mm", "dd MMM, yyyy hh:mm:ss a" ) returns the date in the format "05 Oct, 2004 01:25:00 PM."

Note: The complete source code and deployable formatDate function can be found in the examples\FunctionsSamplePlugin in the IBM® Rational® Integration Tester installation.

Feedback