<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Practically Agile &#187; date</title>
	<atom:link href="http://practicallyagile.com/tag/date/feed/" rel="self" type="application/rss+xml" />
	<link>http://practicallyagile.com</link>
	<description>Using Agile in less-than-perfect situations since Y2K</description>
	<lastBuildDate>Mon, 27 Dec 2010 18:15:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Java Dates Still Suck</title>
		<link>http://practicallyagile.com/2009/05/java-dates-still-suck/</link>
		<comments>http://practicallyagile.com/2009/05/java-dates-still-suck/#comments</comments>
		<pubDate>Fri, 29 May 2009 14:28:06 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://practicallyagile.com/?p=90</guid>
		<description><![CDATA[At the risk of this becoming a bile blog, I have another Java rant. It has been a long-standing tradition (12 years?) among Java developers to cry out that the date implementation in Java is pretty terrible. So, it&#8217;s not just me As a bit of history, the folks at Sun (soon to be Oracle) [...]]]></description>
			<content:encoded><![CDATA[<p>At the risk of this becoming a bile blog, I have another Java rant. It has been a long-standing tradition (12 years?) among Java developers to cry out that the date implementation in Java is pretty terrible. So, it&#8217;s not just me</p>
<p>As a bit of history, the folks at Sun (<a title="Oracle Buys Sun" href="http://www.oracle.com/us/corporate/press/018363">soon to be Oracle</a>) tried to fix this by all but requiring that <code>Date</code> objects be wrapped with <code>Calendar</code> objects in JDK 1.1. They couldn&#8217;t just fix the date implementation directly because of another long-standing tradition: new Java versions must be backward-compatible with previous versions. Regardless, this fix has long been considered a kludge at best, but most of us learned to live with it. Preamble out of the way&#8230;</p>
<p>I was working with someone today who had a <code>Calendar</code> object. They wanted to compare it with another object to see which was earlier. So, they called <code>Calendar.after(Object)</code>. Makes sense right? Only this method returned <code>false</code> even when the other object was definitively a representation of a time after that represented by the <code>Calendar</code> object. This seemed odd to the developer in question.</p>
<p>The observant among you may have noticed that I did not say they were comparing with another <code>Calendar</code> object. They were, in fact, comparing against a <code>Date</code> object. Knowing that, I immediately suspected the problem. A quick trip to the <a title="Calendar.after(Object) API Javadoc" href="http://java.sun.com/javase/6/docs/api/java/util/Calendar.html">API docs</a> showed me this gem:</p>
<blockquote><p>Returns whether this <code>Calendar</code> represents a time  after the time represented by the specified  <code>Object</code>&#8230; if and only if <code>when</code> is a <code>Calendar</code> instance. Otherwise, the method returns <code>false</code>.</p></blockquote>
<p>So, rather than throwing an <code>IllegalArgumentException</code> or having the method specifically only take a <code>Calendar</code> object, this method and the corresponding <code>before(Object)</code> method both just return <code>false</code> when you send in&#8230; anything else. So <code>Calendar.after("dates in Java suck")</code> returns <code>false</code>.</p>
<p>There are no good reasons for this that I can think of, so I went to the <a title="Sun's Bug Database" href="http://bugs.sun.com/bugdatabase/">Bug Parade</a>. There, I found a few tickets that were marked as fixed or otherwise closed. However, this is still obviously a problem, right? Refining my search, I found what I think is <a title="Bug ID: 6609391" href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6609391">the most recent one</a>. It is marked as &#8220;Closed, Will Not Fix&#8221;. Why? Here is the relevant part of the comment:</p>
<blockquote><p>It&#8217;s hard to change the implementation at this point. Please use compareTo(Calendar) added in 1.5.0.</p></blockquote>
<p>I&#8217;m sorry, can&#8217;t we at least deprecate things that are this broken? Do we not do that after the heckling caused by deprecating 60% of the methods in <a title="java.util.Date API Javadocs" href="http://java.sun.com/javase/6/docs/api/java/util/Date.html">Date</a>?</p>
<p>A follow up question&#8230; Where is the replacement library? We had <code>java.nio</code>, why not create a new <code>java.date</code>? For that matter, why hasn&#8217;t a third party library really taken off here? My suspicion is that JPA integration is the main challenge. Especially since, in addition to the problem of them having the same class name, <code>java.sql.Date</code> extends <code>java.util.Date</code>.</p>
<p>Maybe I&#8217;ll try out <a title="Joda Time on Sourceforge" href="http://joda-time.sourceforge.net/index.html">Joda Time</a> or another 3rd party replacement. Does anyone know how their Hibernate sub-project works in the field? (Update: The goal of <a title="JSR-310 project page on java.net" href="https://jsr-310.dev.java.net/">JSR-310</a> is actually to get Joda Time into core Java. It had been tentatively scheduled for Java 1.7. A quick look around shows that there was some struggling to get it completed and tested for inclusion. I was not able to determine an outcome. Anyone know?)</p>
<p>I&#8217;ll try to make my next post about something more positive.</p>
]]></content:encoded>
			<wfw:commentRss>http://practicallyagile.com/2009/05/java-dates-still-suck/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

