I have a web application that sends out an email containing details about an event. The email uses a Velocity template sent by a Java backend. This application is hosted on a Tomcat server located in Brazil.
When the event date is included in the email I see the following
Data e Horário da Conferência (Conference Date): Mon Feb 05 10:45:00 BRST 2018
Since the application is hosted in Brazil, the date/time and timezone are correct, however I would like to print the date out like:
Data e Horário da Conferência (Conference Date): Seg 05 Fev 10:45:00 BRST 2018
Notice the spelling of the day and month.
Is there a way to achieve this in the Velocity file or in Java? Or is it possible that I need to change some Tomcat settings?
Example:
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Duser.country=BR -Duser.language=pt"
Any help is greatly appreciated!
You can use velocity's DateTool which is part of velocity tools (jar)
The methods of this tool are highly interconnected, and overriding key methods provides an easy way to create subclasses that use a non-default format, calendar, locale, or timezone.
Add it to context of velocity:
context.put("date", new DateTool());
and then use toDate/format functions
format(String format, Object obj, Locale locale) Converts the specified object to a date and returns a formatted string representing that date in the specified Locale.
$date.format(....)