title: Date conversion
body: <p>I have a date variable </p>
  
  <pre><code>var date: Date = new Date()
  </code></pre>
  
  <p>then I have converted this date to String:</p>
  
  <pre><code>var dateStr = date.toString()
  </code></pre>
  
  <p>now I need to convert back this String to date.
  I have tried both:</p>
  
  <p>1:</p>
  
  <pre><code>   var stringToDate: Date = date2Str.asInstanceOf[Date]
  </code></pre>
  
  <p>and 2:</p>
  
  <pre><code>stringToDate: Date = new SimpleDateFormat("dd.MM.yyyy").parse(dateStr);
  </code></pre>
  
  <p>But in both case I got the error:</p>
  
  <pre><code>java.lang.ClassCastException:
  java.lang.String cannot be cast to java.util.Date
  </code></pre>