Covering the first day of the week in joda?
Is it possible to rewrite the first day of Joda Week to Sunday? Because Joda uses Monday as the first day of the week.
If there is a way, can anyone explain it?
I cited the following topics in SOF
Thanks
Solution
No.
First, covering the first day of the week as Sunday will require covering all other working days. But these final constants are found in the class DateTimeConstants is not possible to override. But you don’t want to override these values anyway because it would disrupt joda-time’s ISO compliance.
At the same time I wonder why you want to cover it in the first place? Can you provide a use case?
public static DateTime getUSFirstDayOfWeek(DateTime dateTime) {
return dateTime.withDayOfWeek(DateTimeConstants.MONDAY).minusDays(1);
}
This simple helper method might get the job done. NOTE THAT I DID NOT USE SUNDAY
BECAUSE IT WILL HAPPEN IN THE FUTURE, ACCORDING TO THE AMERICAN CONCEPT, THIS IS ALREADY NEXT WEEK.