我有一個csv文件,我想用fmpp(freemarker)進行轉換。第一列是一個很長的值(從1970年1月1日開始,毫秒),我想將其轉換爲日期並將其格式化爲日期時間。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
我(運行)模板:
<#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>
對於列0我想要做的轉換。我不想寫一個包含日期的新模型。我的問題是,這可以在模板中完成,而無需修改freemarker或fmpp。
有什麼想法?
感謝名單!我必須在文檔中監督這一點。給別人一個提示。您必須首先將字符串轉換爲數字,然後再轉換爲像這樣的日期時間:$ {(row [h])?number?number_to_datetime}。輸出的日期時間格式可以設置爲:<#setting datetime_format =「yyyy-MM-dd hh:mm:ss」> – Andreas