<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Find the Difference Between two Java Dates (Calendars)</title>
	<atom:link href="http://www.gadberry.com/aaron/2007/08/17/find-the-difference-between-two-java-dates-calendars/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gadberry.com/aaron/2007/08/17/find-the-difference-between-two-java-dates-calendars/</link>
	<description>Help - v. helped, helpÂ·ing, helps</description>
	<lastBuildDate>Fri, 25 Jun 2010 14:18:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Dragan</title>
		<link>http://www.gadberry.com/aaron/2007/08/17/find-the-difference-between-two-java-dates-calendars/comment-page-1/#comment-21592</link>
		<dc:creator>Dragan</dc:creator>
		<pubDate>Sat, 06 Dec 2008 18:50:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.gadberry.com/aaron/2007/08/17/find-the-difference-between-two-java-dates-calendars/#comment-21592</guid>
		<description>Thanks for posting this online. It really helped me. I just can&#039;t believe there is no such util included with  standard jdk.</description>
		<content:encoded><![CDATA[<p>Thanks for posting this online. It really helped me. I just can&#8217;t believe there is no such util included with  standard jdk.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Naren</title>
		<link>http://www.gadberry.com/aaron/2007/08/17/find-the-difference-between-two-java-dates-calendars/comment-page-1/#comment-8000</link>
		<dc:creator>Naren</dc:creator>
		<pubDate>Sat, 08 Mar 2008 15:41:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.gadberry.com/aaron/2007/08/17/find-the-difference-between-two-java-dates-calendars/#comment-8000</guid>
		<description>Hi 
I think you should use
&lt;code&gt;
unitEstimates.put(Calendar.MONTH, 1000l * 60 * 60 * 24 * 28); 
&lt;/code&gt;
instead of 
&lt;code&gt;
unitEstimates.put(Calendar.MONTH, 1000l * 60 * 60 * 24 * 30); 
&lt;/code&gt;
in the differenceGetUnitEstimates() method
For example  as the code stands today - it returns the difference  in months between Feb 7, 2008 and Mar 7, 2008 as 0(zero)
This is because Feb has only 29 days and the code snippet in difference(Calendar c1, Calendar c2, int unit) 
&lt;code&gt;
long increment = (long) Math.floor((double) difference / (double) unitEstimate);
&lt;/code&gt;
returns zero as the increment as a result
The while loop skips over an zero increment value. 
&lt;code&gt;
while (increment &gt; 0) {
&lt;/code&gt;

The fix I suggested was based on the observation that every month has 28 days (leap year february included) and the basic logic of finding the number of months elapsed based on the increments still is a fundamentally strong idea
Let me know what you think. I have done some testing on this as well and it works.</description>
		<content:encoded><![CDATA[<p>Hi<br />
I think you should use<br />
<pre><code>
unitEstimates.put(Calendar.MONTH, 1000l * 60 * 60 * 24 * 28); 
</code></pre><br />
instead of<br />
<pre><code>
unitEstimates.put(Calendar.MONTH, 1000l * 60 * 60 * 24 * 30); 
</code></pre><br />
in the differenceGetUnitEstimates() method<br />
For example  as the code stands today &#8211; it returns the difference  in months between Feb 7, 2008 and Mar 7, 2008 as 0(zero)<br />
This is because Feb has only 29 days and the code snippet in difference(Calendar c1, Calendar c2, int unit)<br />
<pre><code>
long increment = (long) Math.floor((double) difference / (double) unitEstimate);
</code></pre><br />
returns zero as the increment as a result<br />
The while loop skips over an zero increment value.<br />
<pre><code>
while (increment &gt; 0) {
</code></pre></p>
<p>The fix I suggested was based on the observation that every month has 28 days (leap year february included) and the basic logic of finding the number of months elapsed based on the increments still is a fundamentally strong idea<br />
Let me know what you think. I have done some testing on this as well and it works.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stucco</title>
		<link>http://www.gadberry.com/aaron/2007/08/17/find-the-difference-between-two-java-dates-calendars/comment-page-1/#comment-7961</link>
		<dc:creator>Stucco</dc:creator>
		<pubDate>Thu, 06 Mar 2008 05:19:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.gadberry.com/aaron/2007/08/17/find-the-difference-between-two-java-dates-calendars/#comment-7961</guid>
		<description>Updated the code 3/5/2008 to fix a bug where the estimated time was greater than the actual time passed, yet the time passed was sufficient to be a single unit.  For example Feb 1st to March 1st.  Thank you Tim for catching this bug.</description>
		<content:encoded><![CDATA[<p>Updated the code 3/5/2008 to fix a bug where the estimated time was greater than the actual time passed, yet the time passed was sufficient to be a single unit.  For example Feb 1st to March 1st.  Thank you Tim for catching this bug.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: naren</title>
		<link>http://www.gadberry.com/aaron/2007/08/17/find-the-difference-between-two-java-dates-calendars/comment-page-1/#comment-4700</link>
		<dc:creator>naren</dc:creator>
		<pubDate>Sun, 21 Oct 2007 21:48:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.gadberry.com/aaron/2007/08/17/find-the-difference-between-two-java-dates-calendars/#comment-4700</guid>
		<description>neat idea to get over those leap year issues!</description>
		<content:encoded><![CDATA[<p>neat idea to get over those leap year issues!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
