Jump to content
We've recently updated our Privacy Statement, available here ×

bigcalm

Members
  • Posts

    1
  • Joined

  • Last visited

bigcalm's Achievements

Newbie

Newbie (1/14)

  • First Post Rare
  • Week One Done
  • One Month Later
  • One Year In

Recent Badges

0

Reputation

  1. Formatting date is fairly easy, just use: (new SimpleDateFormat("dd/MM/yyyy")).format($F{ca_call_date}) set the output field to be a string. To format an integer value into a duration in terms of hh:mm:ss I found much harder - what I ended up doing was making sure that my classpath could include some existing java code and then calling a custom function to do it. Code in the jasper report was... (new imcl.common.lib.MobileDurationFormatter()).format($F{ca_call_duration}) The related code was.. public String format( Object object ) { Integer duration = null; if ( object instanceof Double ) { Double dble = (Double) object; duration = dble.intValue(); } else { duration = (Integer) object; } Tracer.getTracer().println( " duration '" + duration + "'" ); int seconds = duration % 60; int minutes = ( duration % 3600 ) / 60 ; int hours = duration / 3600 ; Tracer.getTracer().println( " seconds '" + seconds + "'" ); Tracer.getTracer().println( " minutes '" + minutes + "'" ); Tracer.getTracer().println( " hours '" + hours + "'" ); StringBuffer buffer = new StringBuffer( 10 ); buffer.append( hours < 10 ? "0" + hours : hours ); buffer.append( ":" ); buffer.append( minutes < 10 ? "0" + minutes : minutes ); buffer.append( ":" ); buffer.append( seconds < 10 ? "0" + seconds : seconds ); Tracer.getTracer().println( " string '" + buffer.toString() + "'" ); return( buffer.toString() ); }
×
×
  • Create New...