sonnv56 / xdocreport

Automatically exported from code.google.com/p/xdocreport
0 stars 0 forks source link

Format Date in template #379

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Date not format in template
Ex: Sat Mar 08 18:06:07 GMT-03:00 2014

What is the expected output? What do you see instead?
date format in pattern.
Expected output ex:
08/03/2014 ('dd/MM/yyyy')

What version of the product are you using? On what operating system?
version: 1.0.3 and 1.0.4
so: win 8.1

Please provide any additional information below.

I have searched a lot about and have not found what you said about it: 

"...But it can be awfull to do that for the whole fields, so those mapping 
could be generated automaticly by the fields metadata serializer (by using 
annotation, using Class type)

Ex for Date Class type, we could generated automaticly the mapping 

$myDate => $dateUtils.format($myDate, "DD/MM/YYY")

so you could write $myDate in your template docx, and use the model which 
returns a date and format it with some pattern."

link: https://code.google.com/p/xdocreport/issues/detail?id=236

Do you have an example?

GREETINGS,

Original issue reported on code.google.com by jonatha....@gmail.com on 8 Mar 2014 at 10:01

GoogleCodeExporter commented 9 years ago
Hi Jonata,

If you wish to format your date, you can do 

1) with Java code by adding in your Pojo a String getter
2) by using Velocity syntax (see 
https://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generi
c/DateTool.html)/Freemarker syntax (see 
http://freemarker.org/docs/ref_builtins_date.html)

If you the feature that I have explained 

"Ex for Date Class type, we could generated automaticly the mapping 

$myDate => $dateUtils.format($myDate, "DD/MM/YYY")
"

as I said, it's not implemented. It means that you wish the issue 
https://code.google.com/p/xdocreport/issues/detail?id=41

Original comment by angelo.z...@gmail.com on 8 Mar 2014 at 11:06

GoogleCodeExporter commented 9 years ago
Very cool Angelo. 

It worked! 

I switched Velocity to Freemarker. Freemarker has much more features. 

I was so eager to use Velocity that I didn't see this possibility!

Many thanks for the tip.

Original comment by jonatha....@gmail.com on 9 Mar 2014 at 3:16

GoogleCodeExporter commented 9 years ago
Hi Jonata,

Glad Freemarker helped you. I close this issue.

Regards Angelo

Original comment by angelo.z...@gmail.com on 9 Mar 2014 at 9:32