Elegant way to convert "YYYY-MM" to Date object in Java : <p>What is the best way to convert date in String format "YYYY-MM" to Date object in Java apart from String parsing.</p>

<p>What I tried is below.</p>

<pre><code> String expirationDateArr[] = dateStr.split("-");
</code></pre>

<p>Then extract month and year to create the Date object.</p>
