문제

I'm facing difficulties to show the time time difference in hours where hours are greater than 24. Right now I'm using the following in iReport

(new SimpleDateFormat("dd':'HH':'mm':'ss")).format(new Date($V{avgDuration}.longValue()*1000))

where $V{avgDuration} is a variable in jrxml file which is the average time difference between two dates in seconds. Here it shows the 1 day 1 hour but I want it to be 25 hour. What should I do?

도움이 되었습니까?

해결책

I've solved the problem using PeriodFormatterBuilder. But for this, I need to use joda-time library.

In the expression editor of the text box in jrxml file, just wrote the following:

new org.joda.time.format.PeriodFormatterBuilder()
        .printZeroAlways()
        .minimumPrintedDigits(2)
        .appendHours().appendSeparator(":")
        .appendMinutes().appendSeparator(":")
        .appendSeconds()
        .toFormatter()
        .print(new org.joda.time.Period(
            $V{avgDuration}.longValue()*1000))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top