title: Scala: printing a DateTime object in specific format
body: <p>I have a DateTime object and I want to print it with a given format, let's say <code>yyyy-MM-dd</code>.</p>
  
  <p>I've tried</p>
  
  <pre><code>val date = DateTime.now()
  val format = "yyyy-MM-dd"
  println(date.formatted(format))
  </code></pre>
  
  <p>but got <code>yyyy-MM-dd</code> as if the format wasn't recognized.</p>
  
  <p>I also tried</p>
  
  <pre><code>val formatter = new SimpleDateFormat(format)
  println(
  </code></pre>
  
  <p>but got</p>
  
  <blockquote>
    <p>Cannot format given Object as a Date
    java.lang.IllegalArgumentException: Cannot format given Object as a Date</p>
  </blockquote>
  
  <p><strong>How do I print the DateTime object in the format of my choosing?</strong></p>