SunQuest
           Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old April 23rd, 2001, 02:26 AM
kollarao kollarao is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: chennai,india
Posts: 0 kollarao User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
how to find out the differnece in days between two dates

Reply With Quote
  #2  
Old April 24th, 2001, 03:27 PM
wolfespawn wolfespawn is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Posts: 68 wolfespawn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via AIM to wolfespawn
Are you using a database???

Reply With Quote
  #3  
Old April 30th, 2001, 11:45 AM
bdturner bdturner is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: the big smoke - London !
Posts: 0 bdturner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by kollarao
how to find out the differnece in days between two dates


Difference between 2 dates in Java ?
Well - that all depends, but the basic theory I guess is that if you have 2 java.util.Date objects, date1 and date 2, then

long dif = (date1.getTime() - date2.getTime()) / (1000*60*60*24);

which get the difference in milliseconds between the two date objects, and then multiplies it by 1000 (to put it into second), 60 (into minutes), 60 (into hours) and 24 (into days).

And of course this will work for java.sql.Date objects (if you are getting dates out of databases), as they subclass the java.util.Date object.

<disclaimer> I havn't tried the above code - but I think that should all work ! Might need to cast int's or long's somwhere...

Reply With Quote
  #4  
Old April 30th, 2001, 11:59 AM
wolfespawn wolfespawn is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Posts: 68 wolfespawn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via AIM to wolfespawn
Well, if you are getting it out of a database, sql supplies you with functions for it.

You can determine days between, seconds... months.. how many days til next friday... etc...

I was unsure on how to it JAVA-wise...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > difference between dates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway