How to forcefully cast a string(generated by formating some date) into Date?
<p>I have a string (Jan12) (generated by applying some operations on current date {20-jan-2012}) Now i want to convert back this string into Date format . Also the value should be same i.e the new Date object should have value jan12 and not (20-jan-2012) . Pls help . I have tried doing</p>

<pre><code> java.sql.Date.valueOf("Jan12") [this throws IllegalArgumentException]
</code></pre>

<p>and also </p>

<pre><code>new SimpleDateFormat("MMMyy").parse("Jan12") [By this Date gets converted to 20-jan-2012]
</code></pre>

<p><strong>Output required :</strong> A Date Object having value Jan12 (12 is the year)
<strong>My Code :</strong> new java.text.SimpleDateFormat("MMMyy").format(new java.text.SimpleDateFormat("yyyy-MM-dd").parse(s)) // It is a string which gives Jan12</p>

<p>Now i really want to convert <strong>Mycode</strong> into a Date object </p>

<pre><code>    Date now = new Date();                       
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd");  
    String s1 = df.format(now); 
    System.out.println(s1);    // 2012-01-20
    java.sql.Date d111=java.sql.Date.valueOf(s1);
    System.out.println(d111); // 2012-01-20
    DateFormat df1 = new SimpleDateFormat("MMMyy");
    String s2 = df1.format(d111);
    System.out.println(s2);  //Jan12
  Now i want s2 to be converted in Date object 
</code></pre>
