{"id":121,"date":"2004-04-11T08:07:34","date_gmt":"2004-04-11T14:07:34","guid":{"rendered":"http:\/\/www.mooreds.com\/wordpress\/?p=121"},"modified":"2004-04-11T08:07:34","modified_gmt":"2004-04-11T14:07:34","slug":"simpledateformat-and-the-13th-month","status":"publish","type":"post","link":"https:\/\/www.mooreds.com\/wordpress\/archives\/121","title":{"rendered":"SimpleDateFormat and the 13th month"},"content":{"rendered":"<p>Wow.  I just learned something about SimpleDateFormat, a class that I always resort to when I have to convert a String to a Date in java.  Check out this bit of code:<\/p>\n<p><code>import java.text.*;<br \/>\nimport java.util.*;<\/p>\n<p>public class foo {<br \/>\n  public static void main (String[] args) throws Exception {<br \/>\n     SimpleDateFormat sdf = new SimpleDateFormat(\"MMddyyyy\");<br \/>\n     System.out.println(\"12012000 \"+ sdf.parse(\"12012000\"));<br \/>\n     System.out.println(\"13012000 \"+ sdf.parse(\"13012000\"));<br \/>\n     System.out.println(\"12322000 \"+ sdf.parse(\"12322000\"));<br \/>\n  }<br \/>\n}<br \/>\n<\/code><\/p>\n<p>and the output from that code:<\/p>\n<p><code>$ java -classpath . foo<br \/>\n12012000 Fri Dec 01 00:00:00 MST 2000<br \/>\n13012000 Mon Jan 01 00:00:00 MST 2001<br \/>\n12322000 Mon Jan 01 00:00:00 MST 2001<br \/>\n<\/code><\/p>\n<p>Any overflow gets rolled into the the next higher, well, in addition, I&#8217;d call this a place.  The 32nd day of December is the 1st of Jan, and the 13th month of any year is Jan.  This is an implementation detail, as I found no mention of it in the <a href='http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/text\/SimpleDateFormat.html'>SimpleDateFormat<\/a> javadoc, nor the <a href='http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/text\/DateFormat.html'>DateFormat<\/a> javadoc, but <a href='http:\/\/www.geocities.com\/herong_yang\/jdk\/date_format.html'>others have noticed<\/a> this too.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wow. I just learned something about SimpleDateFormat, a class that I always resort to when I have to convert a String to a Date in java. Check out this bit [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-121","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/comments?post=121"}],"version-history":[{"count":0,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/121\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/media?parent=121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/categories?post=121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/tags?post=121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}