覆盖约达一周的第一天? [英] override first day of the week in joda?

查看:135
本文介绍了覆盖约达一周的第一天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以覆盖约达一周的firstday为周日?因为乔达使用的周一为一周的firstday。
任何一个可以请解释我,如果有一种方法。

Is it possible to override the firstday of Joda week to sunday ? since Joda uses Monday as its firstday of the week . Can any one please explain me if there is a way .

我SOF下面提及的主题。

I referred the below Topic in SOF

乔达时间:每周的第一天

感谢

推荐答案

没有。

首先,覆盖一周的第一天至周日将要求覆盖所有其他工作日为好。但是,这些最终常量在类定义 DateTimeConstants ,这是不可能覆盖。但是,你不会想反正,因为它会搞砸乔达时间的ISO-合规覆盖论文值。

First of all, overriding the first day of the week to sunday would require overwriting all other weekdays as well. But these final constants are defined in the class DateTimeConstants, which are impossible to overwrite. But you wouldn't want to override theses values anyways because it would mess up joda-time's ISO-compliance.

同时,我不知道你为什么会想覆盖它摆在首位?你能提供一个用例?

At the same time I wonder why you would want to override it in the first place? Can you provide a use case?

public static DateTime getUSFirstDayOfWeek(DateTime dateTime) {
    return dateTime.withDayOfWeek(DateTimeConstants.MONDAY).minusDays(1);
}

这个简单的辅助方法可能会做这项工作。请注意,我没有使用 SUNDAY ,因为这将是在未来,这就是 - 美国的概念 - 未来一周已

This simple helper method would probably do the job. Notice that I didn't use SUNDAYbecause it would be in the future, which is - in US notion - the next week already.

这篇关于覆盖约达一周的第一天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆