Convert string to date in Scala / Spark

access_time 2 years ago visibility2533 comment 0

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 at 2 years ago copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

Want to publish your article on Kontext?

Learn more

Kontext Column

Created for everyone to publish data, programming and cloud related articles.
Follow three steps to create your columns.


Learn more arrow_forward

More from Kontext

local_offer spark local_offer scala local_offer parquet local_offer spark-file-operations

visibility 21687
thumb_up 0
access_time 3 years ago

In this page, I’m going to demonstrate how to write and read parquet files in Spark/Scala by using Spark SQLContext class. Go the following project site to understand more about parquet. https://parquet.apache.org/ If you have not installed Spark, follow this page to setup: Install Big Data ...

local_offer spark local_offer hdfs local_offer scala local_offer parquet local_offer spark-file-operations

visibility 15391
thumb_up 0
access_time 3 years ago

In my previous post, I demonstrated how to write and read parquet files in Spark/Scala. The parquet file destination is a local folder. Write and Read Parquet Files in Spark/Scala In this page, I am going to demonstrate how to write and read parquet files in HDFS. import ...

local_offer python local_offer spark local_offer hadoop local_offer pyspark

visibility 1508
thumb_up 0
access_time 2 years ago

In one of my previous articles about Password Security Solution for Sqoop , I mentioned creating credential using hadoop credential command. The credentials are stored in JavaKeyStoreProvider. Credential providers are used to separate the use of sensitive tokens, secrets and passwords from the ...

About column

Code snippets and tips for various programming languages/frameworks.

rss_feed Subscribe RSS