<?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: java.util.Calendar.getActualMaximum returns strange results</title>
	<atom:link href="http://blog.smart-java.nl/blog/index.php/2010/01/20/java-util-calendar-getactualmaximum-returns-strange-results/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.smart-java.nl/blog/index.php/2010/01/20/java-util-calendar-getactualmaximum-returns-strange-results/</link>
	<description>Ordina J-Technologies - Java Blog</description>
	<lastBuildDate>Wed, 12 May 2010 21:44:32 +0200</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Frans van Buul</title>
		<link>http://blog.smart-java.nl/blog/index.php/2010/01/20/java-util-calendar-getactualmaximum-returns-strange-results/comment-page-1/#comment-577</link>
		<dc:creator>Frans van Buul</dc:creator>
		<pubDate>Sat, 24 Apr 2010 15:41:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smart-java.nl/blog/?p=643#comment-577</guid>
		<description>Hi Peter,

perhaps this response is a bit late, but I happened to stumble across your blog entry through Google. I would fully agree with Jan-Kees: use Joda Time. Some reasons in addition to those mentioned by Jan-Kees:

-  Joda Time provides for a LocalDate type (pure date, no time, no timezone). This is often exactly what you need to register something like a date of birth. Using java.util.{Date,Calendar}, you&#039;re forced to use an absolute millisecond-since-epoch to represent a date. However, extracting the date part out of a millisecond-since-epoch is time zone dependent. This may cause all kinds of subtle bugs.
-  The Joda Time API is much more suitable for use in a multi-threaded environment, because its value types are immutable and the formatters are thread safe.

There are many more advantages, but I guess these are the most important ones for me.

As for JDK7 and JSR-310: I think it might still be years before JDK7 that&#039;s going to be widely used, I&#039;m certainly not going to wait for that. I hope JSR-310 will become available as well for JDK5/6, but I&#039;m not sure what the status is.

I came across your blog because I&#039;m currently working on a project to get Joda-Time working with Toplink. Currently, JPA/Hibernate support is available, but not JPA/Toplink Essentials and JPA/EclipseLink. I&#039;m gonna post a message on my blog when it&#039;s ready.

Kind regards,
Frans van Buul</description>
		<content:encoded><![CDATA[<p>Hi Peter,</p>
<p>perhaps this response is a bit late, but I happened to stumble across your blog entry through Google. I would fully agree with Jan-Kees: use Joda Time. Some reasons in addition to those mentioned by Jan-Kees:</p>
<p>-  Joda Time provides for a LocalDate type (pure date, no time, no timezone). This is often exactly what you need to register something like a date of birth. Using java.util.{Date,Calendar}, you&#8217;re forced to use an absolute millisecond-since-epoch to represent a date. However, extracting the date part out of a millisecond-since-epoch is time zone dependent. This may cause all kinds of subtle bugs.<br />
-  The Joda Time API is much more suitable for use in a multi-threaded environment, because its value types are immutable and the formatters are thread safe.</p>
<p>There are many more advantages, but I guess these are the most important ones for me.</p>
<p>As for JDK7 and JSR-310: I think it might still be years before JDK7 that&#8217;s going to be widely used, I&#8217;m certainly not going to wait for that. I hope JSR-310 will become available as well for JDK5/6, but I&#8217;m not sure what the status is.</p>
<p>I came across your blog because I&#8217;m currently working on a project to get Joda-Time working with Toplink. Currently, JPA/Hibernate support is available, but not JPA/Toplink Essentials and JPA/EclipseLink. I&#8217;m gonna post a message on my blog when it&#8217;s ready.</p>
<p>Kind regards,<br />
Frans van Buul</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jan-Kees van Andel</title>
		<link>http://blog.smart-java.nl/blog/index.php/2010/01/20/java-util-calendar-getactualmaximum-returns-strange-results/comment-page-1/#comment-384</link>
		<dc:creator>Jan-Kees van Andel</dc:creator>
		<pubDate>Sun, 24 Jan 2010 13:27:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smart-java.nl/blog/?p=643#comment-384</guid>
		<description>I would say, switch to Joda Time. Firstly, because it just works like a charm. (great API)

Second, because it doesn&#039;t have the strange behavior you describe. Check:
&lt;pre class=&quot;brush:java&quot;&gt;
Calendar c = Calendar.getInstance();
c.set(Calendar.MONTH, Calendar.JANUARY);
c.set(Calendar.DAY_OF_MONTH, 31);
c.set(Calendar.YEAR, 2010);

// Construct 31-01-2010 date
DateTime dateTime = new DateTime(c);

// Set month to February
dateTime = dateTime.withMonthOfYear(DateTimeConstants.FEBRUARY);

// Get the max value
int maximumValue = dateTime.dayOfMonth().getMaximumValue();
System.out.println(&quot;Joda maximumValue = &quot; + maximumValue);
&lt;/pre&gt;
--------------
Prints:
Joda maximumValue = 28</description>
		<content:encoded><![CDATA[<p>I would say, switch to Joda Time. Firstly, because it just works like a charm. (great API)</p>
<p>Second, because it doesn&#8217;t have the strange behavior you describe. Check:</p>
<pre class="brush:java">
Calendar c = Calendar.getInstance();
c.set(Calendar.MONTH, Calendar.JANUARY);
c.set(Calendar.DAY_OF_MONTH, 31);
c.set(Calendar.YEAR, 2010);

// Construct 31-01-2010 date
DateTime dateTime = new DateTime(c);

// Set month to February
dateTime = dateTime.withMonthOfYear(DateTimeConstants.FEBRUARY);

// Get the max value
int maximumValue = dateTime.dayOfMonth().getMaximumValue();
System.out.println("Joda maximumValue = " + maximumValue);
</pre>
<p>&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Prints:<br />
Joda maximumValue = 28</p>
]]></content:encoded>
	</item>
</channel>
</rss>
