Date input format vs date output format
tim <[email protected]> Wed, 11 Feb 2015 08:01:14 -0800 (PST)
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Is there any way to set the INPUT format of dates independently from the OUTPUT format of dates?? Background: I am currently in a German context, so I did <#setting locale="de">. I want all date output to be in the German date format, i.e. "dd.MM.yyyy". However from my data model I have the following input format for dates: "dd-MM-yyyy". When I tried to access a date from the data model, it was displayed as-is, i.e. as "dd-MM-yyyy". Then I tried to force Freemarker to parse it as a date using ?date. I got "unparseable date" as a reply. Then I did <#setting date_format="dd-MM-yyyy">. With this setting and using ?date, freemarker accepted the input as a date, but the output was again in the format "dd-MM-yyyy". I then reformatted it to the correct format using ?string, but this is not what I want, because I want to reuse the template for different locales, i.e. I do not want to have locale specific settings while I process the data. I did find a solution to my problem, but I am not sure if this is very elegant. In the beginning I do <#setting date_format="yyyy-MM-dd"> -> set INPUT format ...if current locale is DE then... <#assign output_date_format="dd.MM.yyyy"> -> set OUTPUT format and while processing my data I do (some date)?date?string(output_date_format) This works, but if there is a way to avoid writing ?date?string(output_date_format) behind each and every date, I would be glad. Guess my solution is also not very performant. Ideas? -- View this message in context: http://freemarker.624813.n4.nabble.com/Date-input-format-vs-date-output-format-tp4655367.html Sent from the freemarker-user mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/