Convert string to date in Scala / Spark

event 2019-11-18 visibility 13,586 comment 0 insights
more_vert
insights Stats
Raymond Raymond Code Snippets & Tips

Code snippets and tips for various programming languages/frameworks. All code examples are under MIT or Apache 2.0 license unless specified otherwise. 

This code snippet shows how to convert string to date.

In Scala, java.text.SimpleDateFormat class can be used to to convert string to Date object with user provided date format.

Code snippet

import java.text.SimpleDateFormat
import java.util.Date

val format = new SimpleDateFormat("yyyy-MM-dd")
val date = format.parse("2018-03-03")
More from Kontext
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts