By Alvin Alexander. Last updated: April 19, 2018
Scala date FAQ: How do I determine the day of the year in Scala?
Solution: Use the Java
Calendar class, as shown here:
scala> import java.util.Calendar import java.util.Calendar scala> Calendar.getInstance.get(Calendar.DAY_OF_YEAR) res0: Int = 104
I’m writing this on April 14, 2018, which is the 104th day of the year.