The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
It seems to work for me. You need to realize that these date classes are not meant to measure duration. That is, you will never see 1 Year, 0 Days, because that does not exist on a calendar. I'm assuming you are seeing 11 months, 31 days, and you think that is wrong, when in fact is not wrong at all. Think about it. 11 months, 31 days is exactly the same as 1 year.
It does this because you are storing the difference between dates as a completely different place in time. In your example above:
See, when you subtracted the two, they were 30/31 day months you were dealing with. Now, you are storing it as a completely different year, and since Feb only has 28 days, you now get some extra days. Like I said before, storing a duration in a Date/Calendar isn't what you want to do. [ July 16, 2004: Message edited by: Darin Niard ]
Well, off the top of my head, you could take the "total days person has been alive" and then expand it out. The only problem is, your highest measurement has to be weeks, because after that, it is no longer constant (months and years vary).
Michael, I couldn't try your code since I don't have the right version of the JDK, so I did it my way. It's a little bit longer but I think it works fine. My purpose was to compare the birthdate of my son with the date of some digital photos and then automaticaly write the right label in an album photo.
Here is my code :
Of course, any comment is welcome ! [ July 22, 2004: Message edited by: Franck Tranchant ]