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

Dividing Longs


Recommended Posts

By: Tom Geyzen - tomgeyzen

Dividing Longs

2003-05-16 06:42

Hi,

 

I am using a rather complex function inside a jasper report that parses two string into Longs as milliseconds. The two Longs are then substracted from eachother and the resulting number needs to be converted into a String in order to display hours, minutes and seconds (and not days - eg 2 days = 48 hours ..). I'm using modulo and division to obtain these values.

 

The function works fine in java but when I try to use it in jasper I keep on getting an exception saying "operator / cannot be applied to java.lang.Long,int"

 

From the traces I can tell that Jasper does a getValue on the variable that contains the milliseconds. Is there a way of getting the longValue of the variable so can perform my calculations ?

 

Any suggestions are welcome.

 

Here are the traces:

value = (java.lang.String)(new String((((java.lang.Long)variable_diffMillis.getValue())/3600000) + "h" + ((((java.lang.Long)variable_diffMillis.getValue())%3600000)/60000) + "m" + (((((java.lang.Long)variable_diffMillis.getValue())%3600000)%60000)/1000) + "s"));

 

Thanks,

Tom

 

 

 

 

By: Julie Bé²µbé­ orlibou

RE: Dividing Longs

2003-05-16 08:06

Hi,

 

In your Textfield Expression,

 

You must convert your java.lang.Long in long.

 

Just do that:

 

$F{variable_diffMilliis}.longValue()

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...