How to convert String to date time in Scala?

后端 未结 3 715
别那么骄傲
别那么骄傲 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:34

    If you are using Java's util.Date then like in java:

    val format = new java.text.SimpleDateFormat("yyyy-MM-dd")
    format.parse("2013-07-06")
    

    docs for formating - SimpleDateFormat

    or if you are using joda's DateTime, then call parse method:

    DateTime.parse("07-06-2013")
    

    docs - DateTime

提交回复
热议问题