使用javascripting更改Pentaho中的日期格式

Changing date format in Pentaho using javascripting

我有一个输入 excel sheet,它有一个字段 "fail_date"。我想将格式更改为 dd.MM.yyyy HH:mm:ss。我在下面显示的 javascript 中执行此操作。

var temp = fail_date.getDate();
str2date(temp,"dd.MM.yyyy HH:mm:ss");

但是当我 运行

时出现以下错误

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)

script#5 指向 str2date(temp,"dd.MM.yyyy HH:mm:ss"); 。请帮助解决这个问题。

变量temp被设置为日期类型对象,但是当你应用str2date函数时,这个函数期望是temp as string。

所以你的代码应该是这样的:

var temp = fail_date.getDate();
temp = date2str(temp,"dd.MM.yyyy HH:mm:ss");

记住现在temp是字符串类型