- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在获取时遇到问题 WEEK_OF_YEAR
从日历对象。
by passing date '31-Dec-2014':
calendar1.get(Calendar.WEEK_OF_YEAR) - return 1
by passing date '31-Dec-2015'
calendar1.get(Calendar.WEEK_OF_YEAR) - return 53
by passing date '31-Dec-2016'
calendar1.get(Calendar.WEEK_OF_YEAR) - return 52
by passing date '31-Dec-2017'
calendar1.get(Calendar.WEEK_OF_YEAR) - return 52
by passing date '31-Dec-2018'
calendar1.get(Calendar.WEEK_OF_YEAR) - return 1
Calendar calendar1 = Calendar.getInstance();
calendar1.setTime('31-Dec-2012');
calendar1.set(Calendar.HOUR_OF_DAY, 0);
calendar1.setFirstDayOfWeek(Calendar.MONDAY);
最佳答案
WEEK_OF_YEAR
正如您在 this javadoc 中看到的那样,定义取决于语言环境:
Values calculated for the WEEK_OF_YEAR field range from 1 to 53. The first week of a calendar year is the earliest seven day period starting on getFirstDayOfWeek() that contains at least getMinimalDaysInFirstWeek() days from that year. It thus depends on the values of getMinimalDaysInFirstWeek(), getFirstDayOfWeek(), and the day of the week of January 1. Weeks between week 1 of one year and week 1 of the following year (exclusive) are numbered sequentially from 2 to 52 or 53 (except for year(s) involved in the Julian-Gregorian transition).
关于java - 从日历对象中获取 WEEK_OF_YEAR 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12037825/
更新: 好的,我似乎找到了一半的答案。如果我使用无参数 getInstance 创建我的日历,我得到 WEEK_OF_YEAR = 52。但是,如果我通过向 getInstance 提供 Local.
我在获取时遇到问题 WEEK_OF_YEAR从日历对象。 by passing date '31-Dec-2014': calendar1.get(Calendar.WEEK_OF_YEAR) - r
我尝试通过下面的代码获取一年中的第几周,但它总是返回“3”,我什至将时区设置为 GMT 但仍然返回相同的值(“3”)。请帮帮我这里 DateFormat formatter = new SimpleD
/* package whatever; // don't place package name! */ import java.text.ParseException; import java.te
这个问题已经有答案了: android how to identify the same days of a week (3 个回答) 已关闭 5 年前。 当我执行下面的代码时,我得到相同的输出。 p
Calendar.WEEK_OF_YEAR 无法正常工作。我的目标是每个星期一都是新的一周。我得到的结果在代码注释中。 我的代码是: Calendar cal = Calendar.getInstan
几天来我一直在努力让它发挥作用,但我已经筋疲力尽了。我想我只需要另一双眼睛来帮助我。 我将“条目”存储在数据库中,每个条目在输入时都有一个 Unix 时间戳。我有一个系统,用户可以在其中选择任何日期并
给定 week_of_year,我如何获取该周的开始和结束日期? 示例:假设日期是 2017 年 1 月 1 日。 Calendar calendar = Calendar.getInstance()
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
下面的代码在 Nougat 和 pre-Nougat 上给出了不同的结果。看一看,如果你愿意,可以自己尝试一下。如果有人能向我解释原因并提供解决方案,我将不胜感激。 我想要正确的 WEEK_OF_YE
例如:给定月份 = 2,并给定年份 = 2014,我使用以下代码获得了周列表。为什么我为月份申请 1 是默认月份仅以索引开始。 示例代码: Calendar calendar = Calendar.g
这个问题在这里已经有了答案: Why dec 31 2010 returns 1 as week of year? (6 个答案) Understanding java.util.Calendar
这个问题在这里已经有了答案: Why dec 31 2010 returns 1 as week of year? (6 个答案) 关闭 4 年前。 我试图了解 java.util.Calendar
要么我不理解方法 getActualMaximum(int) 或字段 WEEK_OF_YEAR,要么涉及 Sun 错误(或所有三个)...有人可以向我解释为什么(至少在德语语言环境中...) 以下代码
这个问题已经有答案了: 奥 git _a (1 个回答) 已关闭 6 年前。 我正在执行以下 Java 代码: Calendar cal = Calendar.getInstance(TimeZone
ISO-8601 标准指出 "The first week of a year is the week that contains the first Thursday of the year (an
Mongodb 的 $week operator州 Takes a date and returns the week of the year as a number between 0 and 53
知道年、年中的星期和星期中的日期,就可以获得年中的月份和月份中的日期。例如 // corresponding to September 15, 2012 if week starts on Mond
尝试查找给定日期的星期几。 使用下面的代码。 [Java 1.7] 问题: 2012 年 12 月 29 日 = 第 52 周 2012 年 12 月 30 日 = 第 1 周 2013 年 12 月
好吧,这个难倒我了。我有以下尝试创建此字符串的代码: OUTPUT: 52. 2012 (24 Dec to 30 Dec) 这是 2012 年第 52 周的开始和结束,星期一是一周的第一天。 pri
我是一名优秀的程序员,十分优秀!