I need to calculate the amount of time that has elapsed between two dates using the java.sql.timestamp method -
variables - startTime is passed as a timestamp value and fillTime is passed as a timestamp value
I need the output to display as a double (i.e. startTime - fillTime = 1.48)
JavaJava EE
Last Comment
tagomtech
8/22/2022 - Mon
ksivananth
fillTime.getTime().getTime() - startTime.getTime().getTime() will give you the milisec differences in double!
to get the minutes it returns these errors
TimeUnit.Minutes cannot be resolved to a type
TimeUnit.MilliSeconds cannot be resolved to a type
how can i convert the milliseconds returned by this piece of code
fillTime.getTime() - startTime.getTime()
as it does indeed return the correct milliseconds.
@cehj yes it is a duplicate: I closed that questions out because I felt I had not appropriately asked the question to receive the help I needed....
Let me start over and explain where I am and what I am flustered over.
I am using iReports which has embedded classes or you can import classes
I am using ms sql as the database and CAN NOT change the query
I am trying to convert a crystal report to a iReport (jasperrepoert)
I do not need to write an entire class - I need to be able to use what is given in iReport to configure the information
$V{responsetime} = $F{Crew Filled}.getTime() - $F{Call Started}.getTime() gives me the time as a long: in milliseconds
(($V{responsetime} % (1000*60*60)) / (1000*60)) gives me the correct minutes as a long and then I am casting to double with
$V{minutesResponseTime}.doubleValue() - this gives me the expected results
The issue comes into play when i am trying to get the average response time.
you would think that the minutesResponseTime/timescalled would give me the response time....it does not match with what crystal reports it giving me. SO
here is how crystal reports is figuring it"
to find the minutes between time: (DateDiff ("s", {CC_Report_CrewHistory;1.Call Started}, {CC_Report_CrewHistory;1.Crew Filled}))/60 and we get the same results
to find the average time they are using a built in method that takes the @responsetime evaluates it per data column then uses the group crewname to reset the value.
that value theoretically should be the same in jasper reports but it is not
please see the pics to view the difference.....this is my roadblock and I just cannot see why there is a difference
I REALLY REALLY appreciate you guys helping me with this...
CEHJ
The first image with the yellow highlight looks like you HAVE used a double:
1.6666666666666666667 (or however many recurrences there are) is probably meant to be 1:40 or 1.40
tagomtech
ASKER
I just don't know. I can not see how the results are coming to the listed numbers.
In crystal reports that 1.67 is calculating to 1.89 (This has been why I have pushed the double variable - 1.89 is not minutes and seconds - neither is 1.66) Yes I was able to get it to convert to a double and I thought that would fix the calculation problem!
Any ideas.
The 1.67 is the total time total minutes on the system (5) divided by the number of calls (3)
so the average of calls.
The strange thing is that in crystal reports I get the same number of minutes for each call as I do in my iReports BUT when the average is calculated in Crystal it is returning 1.89 and in iReports it is returning 1.67 the data is the same.
tagomtech
ASKER
puzzle solved -
in crystal reports the data was actually being figured as seconds to a 2 spot decimal then divided by 60
once i went back to seconds - formatted and then divided the reports matched -
i had to drill down in crystal to actually see why the data was being handled differently
>> the data was actually being figured as seconds to a 2 spot decimal then divided by 60
I'm not sure what's worse - a tenth of a minute, or a sixtieth of a second... ;)
tagomtech
ASKER
I know! these reports are just crazy!
I am getting ready to post another question of formatting iReports for weekly runs on the data.
I appreciate you sticking this out with me...as obvious I am having to learn a new program for this job - which seems to have a mind of its own.