Joe Areeda wrote:Well one thing you could do is use the Calendar class.
Get the dates in milliseconds and divide by 86,400,000 (which I think is the number of milliseconds in a day)
Actually, those two solution are mutually exclusive. If you go to the trouble of creating a Calendar, there's not much point in converting it back to a timestamp.
First: neither JDate nor GDate are standard Java date/time classes. They appear to be part of the apache XML beans package.
Second: The solution you adopt will depend on whether timezones are significant. If they are, you will pretty much have to use a Calendar; if not, Joe's solution should be just fine.
Either way, you will have to find out how to convert a JDate/GDate to a regular Java date (java.util.Date). I'm not familiar with the classes, so I can't help you there.
Another possibility: Have a look at Joda Time. It has all sorts of goodies for exactly this kind of stuff and, since you're already using a non-standard package, another one won't make that much difference.
Isn't it funny how there's always time and money enough to do it WRONG?
Joined: Dec 14, 2012
Thank you for replying. I have used the gettimeinmillis from calendar and have implemented it. I got the result. Thanks.
I looked at joda time class. And have used daysimplemented method. but why is it that i m getting 4827 instead of 4826. Could you please explain? below is my code