我有一个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