My psudo code for fetching the time taken for each process in a particular job class looks like this. 

```
                psteps.each {ProcessingStep pstep ->
    List<ExecutionState> states = ProcessingStepUpdate.findAllByProcessingStepAndState(pstep,ExecutionState.blah)
    states.each{ProcessingStepUpdate psu ->
        use(groovy.time.TimeCategory) {
            startTime=pc.started
            endTime=psu.date
            timeTaken = endTime-startTime
            println "Time Taken for ${pc.startJobClass} is ${timeTaken} in ${JCType}"                    
        }
    }
}

```

The code is now not in the form of an array/list and therefore I am not able to calculate the total time taken for each jobclass. 

here is what I tried

```
use(groovy.time.TimeDuration){
        duration=timeTaken.toArray().sum()
        println "Time taken for ${JCType} is ${duration}"
        println "***********************************************************"
    }

```

any idea what the mistake is? I am new to OOPS world and stuck at it in the last 2 days.