Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Scala - How to get the day of the week?

Tags:

scala

Suppose my date format is 21/05/2017 then the output will be SUN.

How can I get the day given a date?

like image 568
Imran Khan Avatar asked Feb 03 '26 15:02

Imran Khan


1 Answers

    import java.time.LocalDate
    import java.time.format.DateTimeFormatter

    val df = DateTimeFormatter.ofPattern("dd/MM/yyyy")
    val dayOfWeek = LocalDate.parse("21/05/2017",df).getDayOfWeek
like image 78
Zernike Avatar answered Feb 05 '26 09:02

Zernike