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
我很难显示小时数超过24小时的时间差。现在我在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?
其中$ V {avgDuration}是jrxml文件中的变量,它是两个日期之间的平均时差(秒)。这里显示的是1天1小时,但我希望它是25小时。我该怎么办?
1 个解决方案
#1
0
I've solved the problem using PeriodFormatterBuilder
. But for this, I need to use joda-time
library.
我已经使用PeriodFormatterBuilder解决了这个问题。但为此,我需要使用joda-time库。
In the expression editor of the text box
in jrxml
file, just wrote the following:
在jrxml文件中的文本框的表达式编辑器中,只写了以下内容:
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))
#1
0
I've solved the problem using PeriodFormatterBuilder
. But for this, I need to use joda-time
library.
我已经使用PeriodFormatterBuilder解决了这个问题。但为此,我需要使用joda-time库。
In the expression editor of the text box
in jrxml
file, just wrote the following:
在jrxml文件中的文本框的表达式编辑器中,只写了以下内容:
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))