Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
Date
raja rajan raja
Greenhorn
Posts: 1
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
how to find the difference between two dates which should return the no of months and days
Amit KumarS
Ranch Hand
Posts: 100
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi..
this might be of some use to you...
import java.util.*; class TestDates{ public static void main(String[] args) { Calendar cal1 = Calendar.getInstance(); cal1.set(2003,10,13); Calendar cal2 = Calendar.getInstance(); cal2.set(2002,10,13); long diff = ((long)(cal1.getTimeInMillis() - cal2.getTimeInMillis())/(1000*60*60*24)); System.out.println("Difference is days: "+diff); } }
i hope this will be of some help to you.. if still in doubt please revert back..
Thanx
Amit
****************************<br />In 24 hrs Earth rotates once on its Axis.
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
how do I find date difference in months
Date Difference without using Date functions
how to covert string to date object?.
Date Function
Dates..
More...