-2

Just want to ask if is there a way to convert this type of date

MM/DD/YYYY (currently on string. Example: "FEBRUARY/20/2020") to 2020-02-20 format as date?

I've tried to use to_date and SimpleDateFormat functions but still doesn't work.

Please help. Thanks.

Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
Skyflakes
  • 28
  • 4
  • 1
    I recommend you don’t use `SimpleDateFormat` and `Date`. Those classes are poorly designed and long outdated, the former in particular notoriously troublesome. Instead use `LocalDate` and `DateTimeFormatter`, both from [java.time, the modern Java date and time API](https://docs.oracle.com/javase/tutorial/datetime/). – Ole V.V. Feb 12 '20 at 07:02
  • check here https://jaceklaskowski.gitbooks.io/mastering-spark-sql/spark-sql-Expression-UnixTimestamp.html https://stackoverflow.com/questions/31134969/how-to-convert-unix-timestamp-to-date-in-spark – Giri Feb 12 '20 at 07:16

1 Answers1

0

Scala does not have its own Date formatting functions. All of it is inherited from Java. So you will have to use SimpleDateFormat or any other available Java alternatives. That will completely work with Scala

Sparker0i
  • 1,787
  • 4
  • 35
  • 60