Results 1 to 4 of 4
Thread: Difference of Two Dates
- 09-15-2009, 02:19 PM #1
Member
- Join Date
- Aug 2009
- Posts
- 56
- Rep Power
- 0
-
- 09-15-2009, 05:30 PM #3
Member
- Join Date
- Aug 2009
- Posts
- 56
- Rep Power
- 0
I have tried this but I don't know how to put the 10/10/2010 in a way that can be subtracted, sdf.format(date.getTime()) has 12/12/2012.
Java Code:long difference = sdf.format(date.getTime()) - 10/10/2010;
-
GregorianCalendar and Calendar (on which the former is based) have methods that can help you here, especially the get(int field) method. If you look at the beginning of the GregorianCalendar API you'll even see sample code that shows how to use the get method. Have a look and give it a try.
GregorianCalendar (Java Platform SE 6)
Similar Threads
-
JTable and Dates
By paluee in forum AWT / SwingReplies: 0Last Post: 03-30-2009, 08:02 PM -
[Very Urgent] Need help calculating difference between two dates
By rustix in forum Advanced JavaReplies: 23Last Post: 02-19-2009, 05:24 AM -
Help with dates
By bumblyb33 in forum New To JavaReplies: 1Last Post: 02-13-2009, 02:54 PM -
How to Compare two Dates
By Java Tip in forum java.utilReplies: 1Last Post: 06-24-2008, 07:05 AM -
No fo days between two dates
By Java Tip in forum Java TipReplies: 0Last Post: 01-28-2008, 09:06 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks