parsing only the Year in a DateFormat Java
<p>I get a returned parsed JSON result with string values in the form of dates like "27-11-2012" which i parse to a date Object. my code for this is:</p>

<pre><code>public Date stringToDateReport(String s){
        //Log.d(TAG,    "StringToDateReport here is " + s);
        DateFormat format;
        Date date = null;

        //if(s.matches(""))
         format = new SimpleDateFormat("dd-MMM-yyyy");

        try {

            date = (Date)format.parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
</code></pre>

<p>now my issue is, a feature has been implemented that sometimes the json only returns a year object like "2012" and is giving me an "ParseException: Unparseable date" as expected. I was thinking of using regex to match the string pattern and parse from there, but not sure how to do that. Any ideas and also anyway to parse only year in a DateFormat?</p>
