How do I format correctly a time Field in Jasper Reports ?

0

Hello good afternoon I want to ask if someone would be able to help me out with a problem that I have with giving the right format to a field in jasper reports.
What I want to do is to display a number of hours of a field type time, this is what I have made by far:

<textFieldExpression><![CDATA[new java.text.SimpleDateFormat("hh:mm").format($F{TIEMPO_SOPORTE})]]></textFieldExpression>

The result I get with that sentence are pretty much what I want to see, but you see right now my problem is that I get some of information incorrectly because if the time is less than an hour I get 12: preceding the minutes.

Example:

If the field on the database says that the time is 0:15 minutes, the reports says that the information is 12:15.
But the data says that the time is more than an hour it displays it correctly.

So I wonder if someone could help me out with this problem?

csrchvz15's picture
Joined: Mar 5 2020 - 7:54pm
Last seen: 6 months 3 days ago

2 Answers:

1

After some search I've found out that, if you want to format time in MySQL and MariaDB this is the sentence you should use:

SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(TIEMPO_SOPORTE))) AS HorasSoporte FROM YOUR_TABLE

 

csrchvz15's picture
Joined: Mar 5 2020 - 7:54pm
Last seen: 6 months 3 days ago
0

You must format the field as a String

csrchvz15's picture
Joined: Mar 5 2020 - 7:54pm
Last seen: 6 months 3 days ago
Feedback
randomness