简体   繁体   English

如何在Jasper中格式化间隔类型

[英]How can I format an interval type in Jasper

I have a query to returning a column that is postgres "interval" type. 我有一个查询要返回的是postgres“间隔”类型的列。 How can I format this field to show the duration as HH:mm? 如何格式化此字段以将持续时间显示为HH:mm? I tried a few different types for the Expression Class like java.lang.String java.util.Date and java.sql.Timestamp and set HH:mm in the Pattern property but it always just outputs like this 我为表达式类尝试了几种不同的类型,例如java.lang.String java.util.Date和java.sql.Timestamp,并在Pattern属性中设置了HH:mm,但它始终只是这样输出

0 years 0 mons 0 days 1 hours 30 mins 0.00 secs 0年0星期一0天1小时30分钟0.00秒

Also tried new SimpleDateFormat("MM:mm").format($F{duration}) 还尝试了new SimpleDateFormat("MM:mm").format($F{duration})

Looks like it's a org.postgresql.util.PGInterval type so the available methods are getMinutes(), getHours() etc. 看起来是org.postgresql.util.PGInterval类型,所以可用的方法是getMinutes(),getHours()等。

http://jdbc.postgresql.org/development/privateapi/org/postgresql/util/PGInterval.html http://jdbc.postgresql.org/development/privateapi/org/postgresql/util/PGInterval.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM