you can calcaulate the diff thru
long l1=date1.getTime();
long l2=date2.getTime();
long difference=l2 - l1;
this gives the difference in milliseconds.
so u can divide it first by thousand to get the no. of seconds, and then by
3600 to get the no. of hours and so on...
Hope it's useful
Niraj
Vipul Shah <[EMAIL PROTECTED]> on 10/06/2000 02:38:46 AM
Please respond to "A mailing list for discussion about Sun Microsystem's
Java Servlet API Technology."
<[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc: (bcc: Niraj Nath/India/IBM)
Subject: Calculating Time Diff
Hi Friends,
This is not specific to servlet, but it's more of core java query.
I have create time instance in miliseconds. Need to get the diff. And want
to
diplay again in time (but not within 24 hrs range).
Here is code I am using :
java.util.Date date = new java.util.Date();
java.sql.Date dt = new java.sql.Date(date.getTime()); // dt=yyyy-mm-dd
java.sql.Time t1 = new java.sql.Time(date.getTime());
java.sql.Time t2 = new java.sql.Time(date.getTime()+(25*24*60*1000));
// i.e. Diff between t2 and t1 is of 25 Hours
How can I calculate the diff for t2 and t1, which should display as
25:00:00
Vipul
____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html