Jump to content

seconds to time


Recommended Posts

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

okay you mean this as expression for the field? but than i get this errors:

Error filling print... Error evaluating expression : 
    Source text : String.format("%d:%02d:%02d", $F{avg_call_duration}/3600, ($F{avg_call_duration}%3600)/60, ($F{avg_call_duration}%60))

Setting up the file resolver... 
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : 
    Source text : String.format("%d:%02d:%02d", $F{avg_call_duration}/3600, ($F{avg_call_duration}%3600)/60, ($F{avg_call_duration}%60)) 
    at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:203) 
    at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591) 
    at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559) 
    at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:884) 
    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:425) 
    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:406) 
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:257) 
    at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:457) 
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2037) 
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:771)


Link to comment
Share on other sites


As alternative, we could use java.util.Date and TimeZone instances in the textfield expression to do the work:

- set the textfield pattern as desired: "HH:mm:ss";

- if the my_data field value is given in seconds, apply the following textfield expression:

<textField pattern="HH:mm:ss">
  <textFieldExpression><![CDATA[new java.util.Date($F{my_data} * 1000 - java.util.TimeZone.getDefault().getOffset($F{my_data} * 1000))]]></textFieldExpression>



Link to comment
Share on other sites

  • 10 years later...
  • 8 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...