title: How to change datatype of columns in a dataframe based on a case class in scala/spark
body: <p>I am trying a convert data type of some columns based on a case class.</p>
  <pre><code>val simpleDf = Seq((&quot;James&quot;,34,&quot;2006-01-01&quot;,&quot;true&quot;,&quot;M&quot;,3000.60),
                       (&quot;Michael&quot;,33,&quot;1980-01-10&quot;,&quot;true&quot;,&quot;F&quot;,3300.80),
                       (&quot;Robert&quot;,37,&quot;1995-01-05&quot;,&quot;false&quot;,&quot;M&quot;,5000.50)
                   ).toDF(&quot;firstName&quot;,&quot;age&quot;,&quot;jobStartDate&quot;,&quot;isGraduated&quot;,&quot;gender&quot;,&quot;salary&quot;)
  
  // Output
  simpleDf.printSchema()
  root
  |-- firstName: string (nullable = true)
  |-- age: integer (nullable = false)
  |-- jobStartDate: string (nullable = true)
  |-- isGraduated: string (nullable = true)
  |-- gender: string (nullable = true)
  |-- salary: double (nullable = false)
  </code></pre>
  <p>Here I wanted to change the datatype of <code>jobStartDate</code> to Timestamp and <code>isGraduated</code> to Boolean. I am wondering if that conversion is possible using the case class?
  I am aware this can be done by casting each column but in my case, I need to map the incoming DF based on a case class defined.</p>
  <pre><code>case class empModel(firstName:String, 
                         age:Integer, 
                         jobStartDate:java.sql.Timestamp, 
                         isGraduated:Boolean, 
                         gender:String,
                         salary:Double
                        )
  
  val newDf = simpleData.as[empModel].toDF
  newDf.show(false)
  </code></pre>
  <p>I am getting errors because of the string to timestamp conversation. Is there any workaround?</p>