ANS-0249 · PRINTING, PDF & EMAIL TEMPLATES
How to Customize Date Format and Locale in NetSuite Advanced PDF/HTML Templates?
Customize date formats and locale in NetSuite Advanced PDF/HTML templates.
Short answer
Customize date output in NetSuite Advanced PDF/HTML templates by declaring a format, e.g., `<#assign custDateFormat "dd MMMM yyyy"/>`, then applying it to a date field: `${record.trandate?string(custDateFormat)}`. To change the language for dates, set the locale using `<#setting locale “fr_CA”>`.
Scenario
NetSuite users often require specific date formats or language-specific date displays in their Advanced PDF/HTML templates, such as invoices or sales orders. The default date output may not align with regional standards or client preferences, necessitating customization within the template's FreeMarker code.
Solution
The solution involves two main aspects: defining a custom date format and, if needed, changing the locale for date output.
Define a Custom Date Format:
First, declare the desired date format within the Advanced PDF/HTML template using the `` directive.
<#assign custDateFormat "dd MMMM yyyy"/>Next, apply this custom format to a specific date field, such as record.trandate, using the ?string built-in function.
${record.trandate?string(custDateFormat)}For example, applying the format "dd MMMM yyyy" to a date field would result in an output like "30 April 2014".
Change the Locale for Date Output:
If the requirement is to display dates in a specific language or regional format, the locale can be changed on the fly within the template. Use the `` directive to set the desired locale.
<#setting locale “fr_CA”>Any date fields printed after this line will utilize the specified locale, for instance, "fr_CA" for Canadian French.
Expert NetSuite Support
Need help with this NetSuite issue?
Printing, PDF & Email Templates consulting and configuration support
