title: Scala Spark convert date to a specific format
body: <p>I am reading some JSON file into a data frame and I want to convert a field in it into a specific format,  the JSON file has <code>server_received_time</code> with the following format as String I want to convert it to be like <code>yyyy-MM-dd:hh</code></p>
  
  <pre><code>"server_received_time":"2019-01-26T03:04:36Z"
  </code></pre>
  
  <p>but whatever I tied just returned  <code>null</code></p>
  
  <pre><code>   df.select("server_received_time")
  .withColumn("tx_date", to_date($"server_received_time", "yyy-MM-dd:hh").cast("timestamp"))
  .withColumn("tx_date2", to_timestamp($"server_received_time", "yyy-MM-dd:hh").cast("timestamp"))
  .withColumn("tx_date3", to_date(unix_timestamp($"server_received_time", "yyyy-MM-dd:hh").cast("timestamp")))
  .withColumn("tx_date4", to_utc_timestamp(to_timestamp(col("server_received_time"), "yyyy-MM-dd:hh"), "UTC"))
  .withColumn("tx_date5", to_timestamp($"server_received_time","yyyy-MM-dd:hh"))
  
  .show(10, false)
  
  +--------------------+-------+--------+--------+--------+--------+
  |server_received_time|tx_date|tx_date2|tx_date3|tx_date4|tx_date5|
  +--------------------+-------+--------+--------+--------+--------+
  |2019-02-18T16:02:20Z|null   |null    |null    |null    |null    |
  |2019-02-18T16:02:20Z|null   |null    |null    |null    |null    |
  |2019-02-18T16:02:20Z|null   |null    |null    |null    |null    |
  |2019-02-18T16:02:20Z|null   |null    |null    |null    |null    |
  |2019-02-18T16:02:20Z|null   |null    |null    |null    |null    |
  |2019-02-18T16:02:20Z|null   |null    |null    |null    |null    |
  |2019-02-18T16:02:20Z|null   |null    |null    |null    |null    |
  |2019-02-18T16:02:20Z|null   |null    |null    |null    |null    |
  |2019-02-18T16:02:20Z|null   |null    |null    |null    |null    |
  |2019-02-18T16:02:20Z|null   |null    |null    |null    |null    |
  +--------------------+-------+--------+--------+--------+--------+
  </code></pre>
  
  <p>I want to have the <code>server_received_time</code> in this format <code>yyyy-MM-dd:hh</code></p>