Extra 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 format() function. Using the example of the placement start date:

${placement.dateBegin.format('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

format('dd/MM/yyyy')

01/08/2021

format('d/M/yyyy')

1/8/2021

format('d MMM yyyy')

1 Aug 2021

format('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:

${placement.dateBegin?placement.dateBegin.format('d MMMM yyyy'):""}

This will check that there is a placement dateBegin 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 is 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):""}

Formatting syntax can become complicated. Your existing templates should be your first source of information. Use the content that you already have as you might discover the syntax you are searching for in a previous template. If you have attempted to format a value unsuccessfully don't hesistate to contact Kyloe Support for assistance.

Last updated

Was this helpful?