在groovy中将Date转换为String

时间:2017-09-04 07:58:31

标签: groovy apache-nifi

我想将def date= new Date()转换为字符串,以便我可以创建此表达式def text=data+" "+"http://hjghjghj.ge(Service) /https:jsonparces getting data from taxservice:Successfully received response然后使用文本作为字符串我尝试toString()但是它没有任何更好的想法?

1 个答案:

答案 0 :(得分:0)

您甚至不需要toString(),只需在字符串连接中使用它就可以转换它,但您必须使用String + Date,而不是Date + String,就像在Java中一样。所以要么使用

def text=""+date+" "+"http://hjghjghj.ge(Service) /https:jsonparces  getting data  from taxservice:Successfully received response

def text=(data as String)+" "+"http://hjghjghj.ge(Service) /https:jsonparces  getting data  from taxservice:Successfully received response

def text=data.toString()+" "+"http://hjghjghj.ge(Service) /https:jsonparces  getting data  from taxservice:Successfully received response`