Reputation: 155
It's a question very basic, I know, but I have a little difficulties with that :
I would like to display in velocity the date with the object DateTool but only the month and the year :
In this moment, I know :
Vos détails de rémunération pour le mois de $date.format($c.time)
displays the date entirely but I would like only the month and the year.
I am looking the API but I haven't found yet.
If you have a suggestion.
Ale.
Upvotes: 0
Views: 1910
Reputation: 155
Thanks so much, I resolve the trick ! My solution is :
<p class="noMarTop headSection"><span style="padding-top:10px;">Vos détails de rémunération pour le mois de $date.format(' MMMMM yyyy',$c.time) </span></p>
to display the month and the year completely.
Vos détails de rémunération pour le mois de juillet 2009
Thanks for the links.
Ale.
Upvotes: 0
Reputation: 11611
Check the documentation of the DateTool
class, you'll see several format
methods. The most basic one takes only a date as a parameter, which will use the format configured globally for the date tool. The next one also takes a format string as a parameter, which can either be one of the known keywords, or a formatting string corresponding to the standard Java datetime formatting options (there's a more thorough description along with examples here). So you might want to use something like:
Vos détails de rémunération pour le mois de $date.format('MMMM yyyy', $c.time)
Make sure the system's locale is set to French as well, otherwise you'll have to place a $locale
variable in the context with the Locale.FRENCH
value and use the 3-params method to get the correct name of the month.
Upvotes: 0
Reputation: 11501
What about using a pattern such as:
$date.format('M',$myDate)
Upvotes: 2