473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

convert jsp load time from ms to seconds results in 0

On a jsp page, I declare a startTime variable and an endTime variable. The difference is then calculated and displayed in milliseconds.

Expand|Select|Wrap|Line Numbers
  1. (endTime.getTime() -  startTime.getTime()) 
.... say that equals 208 ms

if I want the date represented in seconds I can simply divide the total by 1000.

Problem is when it's below 1000 such as the example above the value returned for display is 0 sec.

Do I need to set the decimal point somewhere?
Dec 10 '07 #1
3 3507
BigDaddyLH
1,216 Expert 1GB
On a jsp page, I declare a startTime variable and an endTime variable. The difference is then calculated and displayed in milliseconds.

Expand|Select|Wrap|Line Numbers
  1. (endTime.getTime() -  startTime.getTime()) 
.... say that equals 208 ms

if I want the date represented in seconds I can simply divide the total by 1000.

Problem is when it's below 1000 such as the example above the value returned for display is 0 sec.

Do I need to set the decimal point somewhere?
The problem is that when you do integral division, like long/long:
Expand|Select|Wrap|Line Numbers
  1. long interval = ...
  2. double seconds = interval/1000;
The division is integral division -- the result is a long and any remainder is dicarded. The solution is to do floating point division, like double/double:
Expand|Select|Wrap|Line Numbers
  1. double interval = ...
  2. double seconds = interval/1000.0;
Dec 10 '07 #2
Hi BigDaddyLH,

That did the trick.

Thanks for the explanation.
Dec 10 '07 #3
BigDaddyLH
1,216 Expert 1GB
........................Right on!
Dec 10 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Khuong Dinh Pham | last post by:
I have the contents of an image of type std::string. How can I make a CxImage object with this type. The parameters to CxImage is: CxImage(byte* data, DWORD size) Thx in advance
2
by: John Alesse | last post by:
Hi, I've created a very simple winforms control using the c# wizard in VS .net 2003 that is nothing but a System.Windows.Forms.UserControl. There are no other controls on the form It takes IE 12...
6
by: B B | last post by:
Okay, here is what's happening: I have a reasonably fast laptop (1.4 GHz Mobile M, so comparable to 2.5GHz P4) doing .net development. Running Windows XP pro, SP2 IIS is installed and running...
11
by: Jason | last post by:
Hi I have a "problem" i have got a ASP.NET application. in this application i have included logging. in the logging i have logged how many seconds it takes for this application to fully load....
4
by: Ravi Ambros Wallau | last post by:
Hi: We developed a set of ASP.NET Web Applications that never runs in stand-alone mode, but always inside a portal (Rainbow Portal). All modules are copied on that portal. My question is: load...
29
by: Jan | last post by:
Hi: I have an Access database that's been running (in one form or another) for a couple of different clients for a few years. Now a new client has requested that it be implemented with a SQL...
9
by: Simple Simon | last post by:
Java longs are 8 bytes. I have a Java long that is coming in from the network, and that represents milliseconds since Epoch (Jan 1 1970 00:00:00). I'm having trouble understanding how to get it...
0
by: mich_stone | last post by:
Hi all, I am trying to do a load testing of my web service using web-tests. Take one instance. I have one web-test in my scenario. I have set the user pattern as "constant-50 users". I ran the...
39
by: Gilles Ganault | last post by:
Hello, I'm no LAMP expert, and a friend of mine is running a site which is a bit overloaded. Before upgrading, he'd like to make sure there's no easy way to improve efficiency. A couple of...
9
by: myotheraccount | last post by:
Hello, Is there a way to convert a DataRow to a StringArray, without looping through all of the items of the DataRow? Basically, I'm trying to get the results of a query and put them into a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.