Convert string to date in Scala / Spark

visibility 9,101 access_time 3 years ago languageEnglish

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")
info Last modified by Raymond 3 years ago copyright This page is subject to Site terms.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

timeline Stats
Page index 8.38
More from Kontext
Save Spark DataFrame to Teradata and Resolve Common Errors
visibility 641
thumb_up 0
access_time 2 years ago
Turn off INFO logs in Spark
visibility 11,239
thumb_up 0
access_time 2 years ago