Closed GoogleCodeExporter closed 9 years ago
Hi Gaspard,
If I understand you have a long value that you put in the context like this:
------------------------------------------
long longDate = ...
context.put("myDate", longDate);
------------------------------------------
And you wish write a mergefield in your docx :
------------------------------------------
My date : $myDate
------------------------------------------
If it's that, you can create a Java class DateHelper :
------------------------------------------
public class DateHelper {
public static final DateHelper INSTANCE= new DateHelper ();
public String format(long longDate) {
// format long as date
}
}
------------------------------------------
put an helper class in the context DateHelper
------------------------------------------
context.put("d", DateHelper.INSTANCE);
------------------------------------------
And after you can use it in your docx like this :
------------------------------------------
My date : $d.format($myDate)
------------------------------------------
But I suggest you to read Velocity documentation to use static method (never
used).
Hope it will help you.
Regards Angelo
Original comment by angelo.z...@gmail.com
on 21 Sep 2012 at 9:17
thanks a lot.
it works fine.
Regards,
Gaspard
Original comment by gaspardg...@gmail.com
on 24 Sep 2012 at 8:50
Original issue reported on code.google.com by
gaspardg...@gmail.com
on 21 Sep 2012 at 1:59