使用JavaScript更改Pentaho中的日期格式 [英] Changing date format in Pentaho using javascripting
问题描述
我有一个输入excel工作表,该工作表的字段为"fail_date".我想将格式更改为dd.MM.yyyy HH:mm:ss
.我正在下面显示的javascript中执行此操作.
I have an input excel sheet which has a field "fail_date". I want to change the format to dd.MM.yyyy HH:mm:ss
. I am doing this in javascript shown below.
var temp = fail_date.getDate();
str2date(temp,"dd.MM.yyyy HH:mm:ss");
但是我跑步时出现以下错误
But I get the below error when i run
2015/05/07 17:48:01-修改的Java脚本值2 2 2.0-错误 (版本4.4.0稳定,由2012-11-21 16.02.21建立的17588由 buildguy):无法在字符串上应用给定格式dd.MM.yyyy 对于星期四1月01 11:05:50 IST 1970:Format.parseObject(String)失败 (脚本5)
2015/05/07 17:48:01 - Modified Java Script Value 2 2 2.0 - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : Could not apply the given format dd.MM.yyyy on the string for Thu Jan 01 11:05:50 IST 1970 : Format.parseObject(String) failed (script#5)
脚本#5指向str2date(temp,"dd.MM.yyyy HH:mm:ss");
.请帮助解决此问题.
script#5 points to str2date(temp,"dd.MM.yyyy HH:mm:ss");
. Please help to solve this issue.
推荐答案
变量temp被设置为日期类型对象,但是当您应用str2date函数时,该函数期望将temp作为字符串.
the variable temp is setted as date type object, but when you apply the str2date function, this function expects to be temp as string.
这就是您的代码应为的方式:
So this is how your code should be:
var temp = fail_date.getDate();
temp = date2str(temp,"dd.MM.yyyy HH:mm:ss");
现在记住temp是一个字符串类型
remember now temp is a string type
这篇关于使用JavaScript更改Pentaho中的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!