Changing date format in Pentaho using javascripting

廉价感情. 提交于 2019-12-11 03:07:56

问题


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 - 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 points to str2date(temp,"dd.MM.yyyy HH:mm:ss"); . Please help to solve this issue.


回答1:


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");

remember now temp is a string type



来源:https://stackoverflow.com/questions/30100943/changing-date-format-in-pentaho-using-javascripting

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!