How to convert String to date time in Scala?

后端 未结 3 718
别那么骄傲
别那么骄傲 2020-12-13 02:17

I am new to Scala and I\'ve learned it for the last few days. I have a doubt about Scala\'s date converting from string.

How to convert String to Date and time using

3条回答
  •  不知归路
    2020-12-13 02:27

    My go-to option is to use nscala-time: https://github.com/nscala-time/nscala-time

    Add this to your build.sbt if using sbt.

    libraryDependencies += "com.github.nscala-time" %% "nscala-time" % "1.8.0"
    

    Import and parse your date.

    import com.github.nscala_time.time.Imports._
    
    DateTime.parse("2014-07-06")
    

提交回复
热议问题