Results 1 to 1 of 1
Thread: GregorianCalendar help
- 02-03-2010, 09:43 PM #1
Member
- Join Date
- Feb 2010
- Posts
- 1
- Rep Power
- 0
GregorianCalendar help
Hello, I'm in serious need of help with my program using GregorianCalendar.
I need to find the difference between two dates in months. I've googled for it and haven't found anything but I did find this forum. So here's what I've been using to get the difference and print the result.
However, the Teacher's Aide teaching my class told me there's a simpler way to do this. I can't find it, so any help is appreciated...Java Code:System.out.println("Number of months between your birthday and this date: " + Math.abs(((otherDate.get(Calendar.YEAR)-birthDate.get(Calendar.YEAR))*12)+(otherDate.get(Calendar.MONTH)-birthDate.get(Calendar.MONTH))));
Edit: Solved the next part, so I'll post how. Just need a better way to calculate difference.
Also, is there a way to get the system date using only the GregorianCalendar and not Date?
Yes,
Thanks.Java Code:GregorianCalendar currentDate = new GregorianCalendar();
-SturmLast edited by Sturm; 02-03-2010 at 10:02 PM.
Similar Threads
-
Problem with "GregorianCalendar"
By tola.ch2004 in forum New To JavaReplies: 2Last Post: 07-12-2007, 08:12 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks