[ 
https://issues.apache.org/jira/browse/FREEMARKER-36?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15551058#comment-15551058
 ] 

Daniel Dekany commented on FREEMARKER-36:
-----------------------------------------

{{"${expression}"}} explicitly tells FreeMarker to convert the value of the 
expression to a string, similarly as {{"Hello ${expression}!"}} does. So above 
you have forced FreeMarker to convert {{timeZone}} to string via calling 
{{toString()}}. The result of {{TimeZone.toString()}} is not parseable as a 
time zone ID. So try {{<#setting time_zone=timeZone.id>}}. But it would be 
cleaner if you just use {{Environment.setTimeZone(TimeZone)}} on the Java side 
(see {{Environment}} layer settings on 
http://freemarker.org/docs/pgui_config_settings.html), before processing the 
template. (I have assumed that you have to set the time zone per-template, 
otherwise you would use {{Configuration.setTimeZone}}).

> Datetime is not accepting timezone
> ----------------------------------
>
>                 Key: FREEMARKER-36
>                 URL: https://issues.apache.org/jira/browse/FREEMARKER-36
>             Project: Apache Freemarker
>          Issue Type: Bug
>            Reporter: Tibor Nahalka
>
> In template we have set time-zone as a java TimeZone object. On the input we 
> have timestamp ${timestamp?number_to_datetime}. In the result we see datetime 
> in UTC instead of our timezone.
> On freemarker pages I found that it should depend on timezone:
> These are used to convert a number (usually a Java long) to a date, time or 
> date-time, respectively. This does them same as new java.util.Date(long) in 
> Java, that is, the number is interpreted as the milliseconds passed since the 
> epoch. The number can be anything and of any type as far as its value fits 
> into a long. If the number isn't a whole number, it will be rounded to whole 
> with half-up rule.
> Example:
> ${1305575275540?number_to_datetime}
> ${1305575275540?number_to_date}
> ${1305575275540?number_to_time}
> The output will be something like this (depending on the current locale and 
> time zone):
> May 16, 2011 3:47:55 PM
> May 16, 2011
> 3:47:55 PM



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to