Field formatting

For most fields you will most likely display exactly what is stored in Bullhorn. Dates and numbers may require additional formatting.

Dates

A date is stored in Bullhorn as a UTC datetime. This is usually unacceptable to use:

Sun Aug 01 04:00:00 UTC 2021

To make a date more acceptable we use the formatDate() function. Using the example of the Job Order start date:

${jobOrder.startDate.formatDate("d MMMM yyyy")}

This will format the date as follows:

1 August 2021

There are many possible date formats but a few are provided here:

Format
Result

formatDate("dd/MM/yyyy")

01/08/2021

formatDate("d/M/yyyy")

1/8/2021

formatDate("d MMM yyyy")

1 Aug 2021

formatDate("M-d-yyyy")

8-1-2021

As before, we need to make sure we do not attempt to format a null date. We can protect against this with the full syntax:

${jobOrder.startDate?jobOrder.startDate.formatDate("d MMMM yyyy"):""}

This will check that there is a Job Order startDate value before attempting the formatting.

Numbers

Whole numbers will not require special formatting, but floating-point numbers (including currency values) will need special attention. In order to fix the number of decimal places you can use the sprintf() function. This if of the format:

${sprintf('%,.2f', jobOrder.payRate)}

The .2f portion sets the number of decimal places to display. The % character is mandatory but the , is optional. Adding it will place this character as a thousands separator. A few examples will help:

Format
Result

sprintf('%,.2f', 123456.3456)

123,456.35

sprintf('%,.0f', 123456.3456)

123,456

sprintf('%.1f', 123456.3456)

123456.3

Again, protecting against null values is important. A correct use of sprintf() would be as follows:

${jobOrder.payRate?sprintf('%,.2f', jobOrder.payRate):""}// Some code

Formatting syntax can become complicated. If you have attempted to format a value unsuccessfully don't hesitate to contact Kyloe Support for assistance.

Last updated

Was this helpful?