How do you determine which day of the week is considered the “start” according to a given Locale using Joda-Time?
Point: Most countries use the international standard
I used the following stub in Scala
to obtain first and last days of the week from Joda
DateTime
val today: DateTime = new DateTime()
val dayOfWeek: DateTime.Property = today.dayOfWeek()
val firstDayOfWeek: DateTime = dayOfWeek.withMinimumValue().minusDays(1)
val lastDayOfWeek: DateTime = dayOfWeek.withMaximumValue().minusDays(1)
Note: The minusDays(1)
is only meant to make the week span from Sunday to Saturday (instead of the default Monday to Sunday known to Joda
). For US (and other similar) locales, you can ignore this part