2017-09-04 37 views
0

我想將def date= new Date()轉換爲字符串,以便我可以使此表達式def text=data+" "+"http://hjghjghj.ge(Service) /https:jsonparces getting data from taxservice:Successfully received response然後使用文本作爲字符串我嘗試過toString()但它沒有幫助任何更好的想法?在Groovy中將日期轉換爲字符串

+0

究竟是什麼錯?如果有的話,請提供正確的代碼和錯誤/問題。 – daggett

+0

不能將Date()轉換爲字符串 –

回答

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`