title: Converting string to a formatted date
body: <p>I am trying to convert a string to proper date format using Java's <code>SimpleDateFormat</code>. For some reason, it's not working with certain months like "Mar", "May", "Oct", and "Dec." Can somebody help me? It works fine for all other months.</p>
  
  <pre><code>import java.sql.Date;
  import java.text.SimpleDateFormat;
  
  import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException;
  
  public class test {
      public static void main(String args[]) throws java.text.ParseException {
          try {
              SimpleDateFormat parse = new SimpleDateFormat("dd. MMM yyyy hh:mm:ss");
              SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  
              //why this doesn't work with certain months like Mar, May, Oct, and Dec? otherwise it works fine
  
              String dateTime =   "01. Jun 2010 15:30:32";
              //String dateTime = "07. Mar 2011 15:20:10";
              //String dateTime = "07. May 2011 15:20:10";
              //String dateTime = "07. Oct 2011 15:20:10";
              //String dateTime = "07. Dec 2011 15:20:10";
  
  
              java.util.Date parsed =parse.parse(dateTime);
              System.out.println("formatted: " + formatter.format(parsed));
          } catch(ParseException e) {
              System.out.println("Caught " + e);
          } 
      }
  }    
  </code></pre>