Accessing the metrics value in JSON input field

Hi
I am storing run time of a task in Elastic and on Kibana, I wanted to display the average run time as a string metric in DD:HH:MM:SS format. Is there a way to do that?
I have tried using the following in JSON input but I get a big 'Internal Server Error' message.
"return String.format("%02d:%02d:%02d", new def { doc['l_runtime_in_seconds'].value/(60*60), (doc['l_runtime_in_seconds'].value/60) % 60, doc['l_runtime_in_seconds'].value%60 });"

@majagrubic