|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
how to find out the differnece in days between two dates
|
|
#2
|
|||
|
|||
|
Are you using a database???
|
|
#3
|
|||
|
|||
|
Quote:
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... |
|
#4
|
|||
|
|||
|
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... |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > difference between dates |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|