title: Date and Time in Kotlin
body: <p>I am new to kotlin. And I got a problem.</p>
  <p>I have this code:</p>
  <pre><code>val sdf = SimpleDateFormat(&quot;dd.MM.yyyy&quot;)
  val currentDate = sdf.format(Date())
  println(currentDate)
  
  val stringDate = &quot;12.03.2015&quot;
  val dateFormatter = DateTimeFormatter.ofPattern(&quot;dd.MM.yyyy&quot;, Locale.ENGLISH)
  val millisecondsSinceEpoch = LocalDate.parse(stringDate, dateFormatter)
      .atStartOfDay(ZoneOffset.UTC)
      .toInstant()
      .toEpochMilli()
  println(millisecondsSinceEpoch)
  
  val time = currentDate - millisecondsSinceEpoch
  val Datee = sdf.format(time)
  println(Datee)
  </code></pre>
  <p>But on the line:</p>
  <pre><code>val time = currentDate - millisecondsSinceEpoch
  val Datee = sdf.format(time)
  println(Datee)
  </code></pre>
  <p>I get the error:</p>
  <pre><code>java.lang.IllegalArgumentException: Cannot format given Object as a Date
  </code></pre>
  <p>Please help me how you can fix this. I need to subtract the current date from the date that is in string.</p>
  <p><strong>UPDATE:</strong></p>
  <p>How to subtract one date from another correctly and get the difference in days?</p>