私はfmpp(freemarker)で変換したいcsvファイルを持っています。最初の列は、日付に変換してdatetimeとしてフォーマットしたいlong値(1.1.1970からのミリ秒)です。Freemarkerモデルは、ミリ秒単位でタイムスタンプを変換します
SRC形式:
timeStamp,elapsed,label,responseCode,threadName,dataType,success,bytes,URL,Latency
1319115474244,40142,Login,200,Login 1-2,text,true,862184,http://localhost:8080/xxx,5378
望ましいターゲットフォーマット:
timeStamp;elapsed;label;responseCode;threadName;dataType;success;bytes;URL;Latency
20.12.2011 13:45;40142;Login;200;Login 1-2;text;true;862184;http://localhost:8080/xxx;5378
私の(ランニング)テンプレート:列0の場合
<#list csv.headers as h>${h}<#if h_has_next>;</#if></#list>
<#list csv as row>
<#list csv.headers as h><#if h_index == 0>Do the date magic<#else>${(row[h]!"N/A")?string}</#if>$<#if h_has_next>;</#if></#list>
</#list>
私は、変換をしたいです。私は、日付を含む新しいモデルを書いてはいけません。私の質問は、freemarkerやfmppを変更することなくテンプレートでこれを行うことができるということです。
ありがとう:この
チェック!私はドキュメンテーションでこれを監督したに違いありません。他の人へのヒント。文字列を最初に数値に変換し、次に$ {(row [h])?number?number_to_datetime}のようなdatetimeに変換する必要があります。出力用のdatetime形式は、次のように設定できます。<#setting datetime_format = "yyyy-MM-dd hh:mm:ss"> – Andreas