日历是一种计算时间的系统,其中定义了一年的开始,长度和分部。该术语可以指用于操纵和显示日历数据的软件类或库,或者由人通过应用程序或操作系统用户界面管理的具有相关日期和时间的事件列表。
我收到以下错误: 第 41 行第 3 列错误:映射键重复。 ╷ 41 │syncfusion_flutter_calendar: ^20.1.57 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 但我的第 41 行是 开发依赖项:
将 tkinter 日历 get_date() 日期与 Oracle 数据库中的日期时间字段进行比较:
我正在尝试从 Oracle DB 中提取两个 tkinter 日历日期内的数据,日历中的日期格式为 date_pattern='yyyy-mm-dd' Oracle DB 中的日期是日期时间 yyyy-mm-dd hh:mm:dd,但我保留 g...
如何使用 Joda-Time 根据给定的区域设置确定一周中的哪一天被视为“开始”? 要点:大多数国家/地区使用国际标准星期一作为一周的第一天(!...
我正在尝试在日历程序中创建一个功能,该功能允许我单击按钮来提示用户填写表单(我的尝试是“addEvent”和“Activity”
我在一个项目中使用了一个第三方sdk,其中在其中一个旅程中,正在使用默认的android日历。由于某种原因,当我单击编辑按钮时,会发生这样的情况...
如何使用 Joda-Time 根据给定的区域设置确定一周中的哪一天被视为“开始”? 要点:大多数国家/地区使用国际标准星期一作为一周的第一天(!...
我正在尝试使用带有德语语言环境的日历函数 getDisplayNames() 来获取德语中的星期几。 现在日历 = Calendar.getInstance(); 地图 显示名称 = 现在。
为什么此代码返回0001-02-05? public static String getNowDate() 抛出 ParseException { 返回 Myformat(toFormattedDateString(Calendar.getInstance())); } 我将代码更改为:
11月1日.. Calendar.getInstance().get(Calendar.MONTH); // 打印 10(十月) 如果我们从 0 开始,这是有道理的,但看起来我们没有 Calendar.getInstance().get(日历。
我有一个问题 - 我正在制作一个应用程序,我想在单击按钮时向用户日历添加一个新事件(我有一个 S Planner,所以我正在对其进行测试)。问题是当涉及到日期和时间时 - 它......
当我在日历上单击“上一个”或“下一个”时,月初会显示上个月某天的名称
我正在 Angular 应用程序中开发日历功能,该功能在使用“上一页”和“下一页”按钮导航时显示当前星期。但是,我遇到了一个问题
显示的时间远远超出了我的预期。我正在解析日期字符串并将其转换为毫秒。 年= Integer.parseInt(m1.group(1)); mo = Integer.parseInt(m1.group(2)); 日 = 互联网...
我有一些(Java),我试图简单地从当前日期减去 7 天。在我看来,Calendar.add(..) 应该是使用的方法(以及这里之前的问题......
我正在设置一个 db40 数据库,它填充了我的 Day() 类的实例,该类具有历史记录中当天的销售信息,以及其 ID 的整数。 id 的格式如下:YYYYM...
Kotlin 日历在 Android studio 和 kotlin online 中返回不同的值
在 Android Studio(Kotlin)中: val 日历 = Calendar.getInstance() 日历.set(1900, 0, 7, 0, 0, 0) println(日历.timeInMillis) println(日历.时间) // -2208484952073 // 1 月 7 日星期日 00:00:00 YEKT
在具有自定义样式的 Silverlight 日历中单击日期时出现问题
我是 Silverlight 开发新手,在自定义日历时遇到了问题。具体来说,使用自定义样式时我无法单击日历中的日期。 我的目标是点击...
这是我的代码: 月份是循环传递的。 首先是 0(因为我输入的时候是一月),然后是 1,依此类推。 下个月二月时,该循环将从该日期开始。 1、2 等 整数
我有以下代码,用于显示当天的名称,后跟一组短语。 <!-- // Array of day names var dayNames...</desc> <question vote="39"> <p>我有以下代码,用于显示当天的名称,后跟一组短语。</p> <pre><code><script type="text/javascript"> <!-- // Array of day names var dayNames = new Array( "It's Sunday, the weekend is nearly over", "Yay! Another Monday", "Hello Tuesday, at least you're not Monday", "It's Wednesday. Halfway through the week already", "It's Thursday.", "It's Friday - Hurray for the weekend", "Saturday Night Fever"); var now = new Date(); document.write(dayNames[now.getDay()] + "."); // --> </script> </code></pre> <p>我想做的是将当前周数放在短语后面的括号中。我找到了以下代码:</p> <pre><code>Date.prototype.getWeek = function() { var onejan = new Date(this.getFullYear(),0,1); return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7); } </code></pre> <p>取自<a href="http://javascript.about.com/library/blweekyear.htm">http://javascript.about.com/library/blweekyear.htm</a>,但我不知道如何将其添加到现有的javascript代码中。</p> </question> <answer tick="true" vote="61"> <p>只需将其添加到您当前的代码中,然后调用 <pre><code>(new Date()).getWeek()</code></pre></p> <pre><code><script> Date.prototype.getWeek = function() { var onejan = new Date(this.getFullYear(), 0, 1); return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7); } var weekNumber = (new Date()).getWeek(); var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; var now = new Date(); document.write(dayNames[now.getDay()] + " (" + weekNumber + ")."); </script> </code></pre> </answer> <answer tick="false" vote="20"> <p>如果您已经使用 jQuery-UI(特别是日期选择器):</p> <pre><code>Date.prototype.getWeek = function () { return $.datepicker.iso8601Week(this); } </code></pre> <p>用途:</p> <pre><code>var myDate = new Date(); myDate.getWeek(); </code></pre> <p>更多信息:<a href="http://docs.jquery.com/UI/Datepicker/iso8601Week" rel="noreferrer">UI/Datepicker/iso8601Week</a></p> <p>我意识到这不是一个通用的解决方案,因为它会产生依赖性。然而,考虑到 jQuery-UI 的流行,这可能只是适合某些人 - 就像我一样。</p> <hr/> <p>如果您不使用 jQuery-UI 并且无意添加依赖项。你可以复制他们的 <a href="https://github.com/jquery/jquery-ui/blob/1-12-stable/ui/widgets/datepicker.js#L1106-L1121" rel="noreferrer"><pre><code>iso8601Week()</code></pre></a> 实现,因为它是用纯 JavaScript 编写的,没有复杂的依赖关系:</p> <p></p><div data-babel="false" data-lang="js" data-hide="false" data-console="true"> <div> <pre><code>// Determine the week of the year (local timezone) based on the ISO 8601 definition. Date.prototype.iso8601Week = function () { // Create a copy of the current date, we don't want to mutate the original const date = new Date(this.getTime()); // Find Thursday of this week starting on Monday date.setDate(date.getDate() + 4 - (date.getDay() || 7)); const thursday = date.getTime(); // Find January 1st date.setMonth(0); // January date.setDate(1); // 1st const jan1st = date.getTime(); // Round the amount of days to compensate for daylight saving time const days = Math.round((thursday - jan1st) / 86400000); // 1 day = 86400000 ms return Math.floor(days / 7) + 1; }; console.log(new Date().iso8601Week()); console.log(new Date("2020-01-01T00:00").iso8601Week()); console.log(new Date("2021-01-01T00:00").iso8601Week()); console.log(new Date("2022-01-01T00:00").iso8601Week()); console.log(new Date("2023-12-31T00:00").iso8601Week()); console.log(new Date("2024-12-31T00:00").iso8601Week());</code></pre> </div> </div> <p></p> </answer> <answer tick="false" vote="14"> <p>考虑使用我的“Date.prototype.getWeek”实现,认为比我在这里看到的其他实现更准确:)</p> <pre><code>Date.prototype.getWeek = function(){ // We have to compare against the first monday of the year not the 01/01 // 60*60*24*1000 = 86400000 // 'onejan_next_monday_time' reffers to the miliseconds of the next monday after 01/01 var day_miliseconds = 86400000, onejan = new Date(this.getFullYear(),0,1,0,0,0), onejan_day = (onejan.getDay()==0) ? 7 : onejan.getDay(), days_for_next_monday = (8-onejan_day), onejan_next_monday_time = onejan.getTime() + (days_for_next_monday * day_miliseconds), // If one jan is not a monday, get the first monday of the year first_monday_year_time = (onejan_day>1) ? onejan_next_monday_time : onejan.getTime(), this_date = new Date(this.getFullYear(), this.getMonth(),this.getDate(),0,0,0),// This at 00:00:00 this_time = this_date.getTime(), days_from_first_monday = Math.round(((this_time - first_monday_year_time) / day_miliseconds)); var first_monday_year = new Date(first_monday_year_time); // We add 1 to "days_from_first_monday" because if "days_from_first_monday" is *7, // then 7/7 = 1, and as we are 7 days from first monday, // we should be in week number 2 instead of week number 1 (7/7=1) // We consider week number as 52 when "days_from_first_monday" is lower than 0, // that means the actual week started before the first monday so that means we are on the firsts // days of the year (ex: we are on Friday 01/01, then "days_from_first_monday"=-3, // so friday 01/01 is part of week number 52 from past year) // "days_from_first_monday<=364" because (364+1)/7 == 52, if we are on day 365, then (365+1)/7 >= 52 (Math.ceil(366/7)=53) and thats wrong return (days_from_first_monday>=0 && days_from_first_monday<364) ? Math.ceil((days_from_first_monday+1)/7) : 52; } </code></pre> <p>您可以在此处查看我的公共存储库<a href="https://bitbucket.org/agustinhaller/date.getweek" rel="noreferrer">https://bitbucket.org/agustinhaller/date.getweek</a>(包括测试)</p> </answer> <answer tick="false" vote="13"> <p>如果您想要有用且面向未来的东西,请使用像 MomentJS 这样的库。</p> <pre><code>moment(date).week(); moment(date).isoWeek() </code></pre> <p><a href="http://momentjs.com/docs/#/get-set/week/" rel="noreferrer">http://momentjs.com/docs/#/get-set/week/</a></p> </answer> <answer tick="false" vote="10"> <p>看起来我在<a href="http://weeknumber.net/how-to/javascript" rel="nofollow noreferrer">weeknumber.net</a>找到的这个功能非常准确且易于使用。</p> <pre><code>// This script is released to the public domain and may be used, modified and // distributed without restrictions. Attribution not necessary but appreciated. // Source: http://weeknumber.net/how-to/javascript // Returns the ISO week of the date. Date.prototype.getWeek = function() { let date = new Date(this.getTime()); date.setHours(0, 0, 0, 0); // Thursday in current week decides the year. date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7); // January 4 is always in week 1. let week1 = new Date(date.getFullYear(), 0, 4); // Adjust to Thursday in week 1 and count number of weeks from date to week1. return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7); } </code></pre> <p>如果你像我一样幸运并且需要找到该月的周数,稍微调整一下就可以了:</p> <pre><code>// Returns the week in the month of the date. Date.prototype.getWeekOfMonth = function() { let date = new Date(this.getTime()); date.setHours(0, 0, 0, 0); // Thursday in current week decides the year. date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7); // January 4 is always in week 1. let week1 = new Date(date.getFullYear(), date.getMonth(), 4); // Adjust to Thursday in week 1 and count number of weeks from date to week1. return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7); } </code></pre> </answer> <answer tick="false" vote="4"> <p>如果您已经使用 Angular,那么您可以获利 <a href="https://docs.angularjs.org/api/ng/filter/date" rel="nofollow"><pre><code>$filter('date')</code></pre></a>。</p> <p>例如:</p> <pre><code>var myDate = new Date(); var myWeek = $filter('date')(myDate, 'ww'); </code></pre> </answer> <answer tick="false" vote="3"> <p>我在黑暗中编码(一个挑战),无法查找、引入任何依赖项或测试我的代码。</p> <p>我忘记了舍入的名称(Math.celi),所以我想额外确定我是否正确,并想出了这个代码。</p> <p></p><div data-babel="false" data-lang="js" data-hide="false" data-console="true"> <div> <pre><code>var elm = document.createElement('input') elm.type = 'week' elm.valueAsDate = new Date() var week = elm.value.split('W').pop() console.log(week)</code></pre> </div> </div> 只是一个概念证明,说明如何以其他方式度过这一周<p></p> <p>但我仍然推荐 DOM 不需要的任何其他解决方案。</p> </answer> <answer tick="false" vote="2"> <p>通过添加代码片段,您可以扩展 Date 对象。</p> <pre><code>Date.prototype.getWeek = function() { var onejan = new Date(this.getFullYear(),0,1); return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7); } </code></pre> <p>如果您想在多个页面中使用它,您可以将其添加到一个单独的 js 文件中,该文件必须在其他脚本执行之前首先加载。对于其他脚本,我指的是使用 getWeek() 方法的脚本。</p> </answer> <answer tick="false" vote="2"> <p>所有提出的方法可能会给出错误的结果,因为它们没有考虑夏季/冬季时间的变化。与其使用 86’400’000 毫秒常量来计算两个日期之间的天数,不如使用如下方法:</p> <pre><code>getDaysDiff = function (dateObject0, dateObject1) { if (dateObject0 >= dateObject1) return 0; var d = new Date(dateObject0.getTime()); var nd = 0; while (d <= dateObject1) { d.setDate(d.getDate() + 1); nd++; } return nd-1; }; </code></pre> </answer> <answer tick="false" vote="1"> <p>在支持 <pre><code>week</code></pre> 输入类型的浏览器中,以下函数应该可以工作:</p> <pre><code>function isoWeek(date) { const input = document.createElement('input'); input.type = 'week'; input.valueAsDate = date; return input.value; }; </code></pre> <p>参看。</p> <pre><code>>>> isoWeek(new Date("2022-01-01")) '2021-W52' >>> isoWeek(new Date("2022-01-03")) '2022-W01' >>> isoWeek(new Date("2023-12-14")) '2023-W50' >>> isoWeek(new Date("2024-01-01")) '2024-W01' </code></pre> </answer> <answer tick="false" vote="0"> <p>使用该代码,您可以简单地;</p> <pre><code>document.write(dayNames[now.getDay()] + " (" + now.getWeek() + ")."); </code></pre> <p>(您需要将 <pre><code>getWeek</code></pre> 函数粘贴到当前脚本上方)</p> </answer> <answer tick="false" vote="0"> <p>你会发现这个小提琴很有用。刚刚完成。 <a href="https://jsfiddle.net/dnviti/ogpt920w/" rel="nofollow noreferrer">https://jsfiddle.net/dnviti/ogpt920w/</a> 代码如下:</p> <p></p><div data-babel="false" data-lang="js" data-hide="false" data-console="true"> <div> <pre><code>/** * Get the ISO week date week number */ Date.prototype.getWeek = function () { // Create a copy of this date object var target = new Date(this.valueOf()); // ISO week date weeks start on monday // so correct the day number var dayNr = (this.getDay() + 6) % 7; // ISO 8601 states that week 1 is the week // with the first thursday of that year. // Set the target date to the thursday in the target week target.setDate(target.getDate() - dayNr + 3); // Store the millisecond value of the target date var firstThursday = target.valueOf(); // Set the target to the first thursday of the year // First set the target to january first target.setMonth(0, 1); // Not a thursday? Correct the date to the next thursday if (target.getDay() != 4) { target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7); } // The weeknumber is the number of weeks between the // first thursday of the year and the thursday in the target week return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000 } /** * Get the ISO week date year number */ Date.prototype.getWeekYear = function () { // Create a new date object for the thursday of this week var target = new Date(this.valueOf()); target.setDate(target.getDate() - ((this.getDay() + 6) % 7) + 3); return target.getFullYear(); } /** * Convert ISO week number and year into date (first day of week) */ var getDateFromISOWeek = function(w, y) { var simple = new Date(y, 0, 1 + (w - 1) * 7); var dow = simple.getDay(); var ISOweekStart = simple; if (dow <= 4) ISOweekStart.setDate(simple.getDate() - simple.getDay() + 1); else ISOweekStart.setDate(simple.getDate() + 8 - simple.getDay()); return ISOweekStart; } var printDate = function(){ /*var dateString = document.getElementById("date").value; var dateArray = dateString.split("/");*/ // use this if you have year-week in the same field var dateInput = document.getElementById("date").value; if (dateInput == ""){ var date = new Date(); // get today date object } else{ var date = new Date(dateInput); // get date from field } var day = ("0" + date.getDate()).slice(-2); // get today day var month = ("0" + (date.getMonth() + 1)).slice(-2); // get today month var fullDate = date.getFullYear()+"-"+(month)+"-"+(day) ; // get full date var year = date.getFullYear(); var week = ("0" + (date.getWeek())).slice(-2); var locale= "it-it"; document.getElementById("date").value = fullDate; // set input field document.getElementById("year").value = year; document.getElementById("week").value = week; // this prototype has been written above var fromISODate = getDateFromISOWeek(week, year); var fromISODay = ("0" + fromISODate.getDate()).slice(-2); var fromISOMonth = ("0" + (fromISODate.getMonth() + 1)).slice(-2); var fromISOYear = date.getFullYear(); // Use long to return month like "December" or short for "Dec" //var monthComplete = fullDate.toLocaleString(locale, { month: "long" }); var formattedDate = fromISODay + "-" + fromISOMonth + "-" + fromISOYear; var element = document.getElementById("fullDate"); element.value = formattedDate; } printDate(); document.getElementById("convertToDate").addEventListener("click", printDate);</code></pre> <pre><code>*{ font-family: consolas }</code></pre> <pre><code><label for="date">Date</label> <input type="date" name="date" id="date" style="width:130px;text-align:center" value="" /> <br /><br /> <label for="year">Year</label> <input type="year" name="year" id="year" style="width:40px;text-align:center" value="" /> - <label for="week">Week</label> <input type="text" id="week" style="width:25px;text-align:center" value="" /> <br /><br /> <label for="fullDate">Full Date</label> <input type="text" id="fullDate" name="fullDate" style="width:80px;text-align:center" value="" /> <br /><br /> <button id="convertToDate"> Convert Date </button></code></pre> </div> </div> <p></p> <p>这是纯JS。 里面有很多日期函数,可以让您将日期转换为周数,反之亦然:)</p> </answer> <answer tick="false" vote="0"> <p><a href="https://moment.github.io/luxon/#/" rel="nofollow noreferrer">Luxon</a> 是另一种选择。 Luxon 日期对象有一个 <a href="https://moment.github.io/luxon/api-docs/index.html#datetimeweeknumber" rel="nofollow noreferrer"><pre><code>weekNumber</code></pre></a> 属性:</p> <p></p><div data-babel="false" data-lang="js" data-hide="false" data-console="true"> <div> <pre><code>let week = luxon.DateTime.fromString("2022-04-01", "yyyy-MM-dd").weekNumber; console.log(week);</code></pre> <pre><code><script src="https://cdnjs.cloudflare.com/ajax/libs/luxon/3.0.1/luxon.min.js"></script></code></pre> </div> </div> <p></p> </answer> <answer tick="false" vote="0"> <p>我已经尝试使用上述所有答案中的代码,并且全部返回一月第一周的第 52 周。所以我决定自己写一个,它可以正确计算周数。 <strong>周计数从0开始</strong></p> <p>也许使用循环的品味不好,或者可以将结果缓存在某个地方,以防止在调用函数足够频繁的情况下重复相同的计算。好吧,我为自己做了这个,它满足了我的需要。</p> <p></p><div data-babel="false" data-lang="js" data-hide="false" data-console="true"> <div> <pre><code> Date.prototype.getWeek = function() { // debugger let msWeek = 604800000; // Week in milliseconds let msDay = 86400000; // Day in milliseconds let year = this.getFullYear(); // Get the year //let month = this.getMonth(); // Month let oneDate = new Date(year, 0, 1); // Create a new date based on THIS year let temp = oneDate.getDay(); // Ordinal of the first day let getFirstDay = (temp === 0) ? 6 : temp - 1; // Ordinal of the first day of the current month (0-MO, 6-SU) let countWeek = 0; // Test to confirm week oneDate = new Date(oneDate.getTime() + msDay*(7 - getFirstDay)); if(oneDate.getTime() > this.getTime()){ return countWeek; } // Increment loop while(true){ oneDate = new Date(oneDate.getTime() + msWeek); // Add a week and check if(oneDate.getTime() > this.getTime()) break; countWeek++; } return countWeek + 1; } let s1 = new Date('2022-01-01'); console.log(s1.getWeek()); let s2 = new Date('2023-01-01'); console.log(s2.getWeek()); let s22 = new Date('2023-01-02'); console.log(s22.getWeek()); let s3 = new Date('2024-01-01'); console.log(s3.getWeek()); let s4 = new Date('2025-01-01'); console.log(s4.getWeek()); let s5 = new Date('2022-02-28'); console.log(s5.getWeek()); let s6 = new Date('2022-12-31'); console.log(s6.getWeek()); let s7 = new Date('2024-12-31'); console.log(s7.getWeek());</code></pre> </div> </div> <p></p> </answer> <answer tick="false" vote="0"> <p>我想添加另一个答案。它适用于所有日期,无论时区如何,不使用任何循环或 DOM 对象,并发出正确的(但从零开始的)ISO 8601 周数(即一年中第一个星期四的周是第 0 周)。</p> <pre><code>/** * Gets the ISO 8601 week number (zero-based) using local time. * @param {Date} date A `Date` object. */ function getISOWeek(date) { // get the week's Thursday (over/underflow in date parameter carries over) let thursday = new Date( date.getFullYear(), date.getMonth(), date.getDate() - (date.getDay() + 6) % 7 + 3 // Sunday is 0 ); /* Get January 1 of that Thursday's year. There is no need to find the first Thursday of the year since we round down the difference in weeks in the next step. */ let janFirst = new Date(thursday.getFullYear(), 0, 1); /* The week number is the number of full weeks between `thursday` and `janFirst`. Both dates were created in local time, so to circumvent DST problems, use equivalent UTC dates (same year, month & date but at 00:00:00 in UTC). */ return Math.floor( ( thursday.getTime() - thursday.getTimezoneOffset() * 60000 - janFirst.getTime() + janFirst.getTimezoneOffset() * 60000 ) / 604800000 // milliseconds per week ); } </code></pre> <p>测试特殊情况:</p> <pre><code>/* these dates belong to a week of the previous/next year */ getISOWeek(new Date(2023, 0, 1)) // -> 51 getISOWeek(new Date(2024, 11, 30)) // -> 0 /* Special cases in timezones with DST when year starts on a Thursday (e.g. Europe/Berlin in 2026, with DST transition on March 29). */ getISOWeek(new Date(2026, 2, 29)) // -> 12 getISOWeek(new Date(2026, 2, 30)) // -> 13 </code></pre> </answer> <answer tick="false" vote="-1"> <p>我在这里看到的一些代码<strong>失败了</strong>,比如 2016 年,第 53 周跳到了第 2 周。</p> <p>这是修订后的工作版本:</p> <pre><code>Date.prototype.getWeek = function() { // Create a copy of this date object var target = new Date(this.valueOf()); // ISO week date weeks start on monday, so correct the day number var dayNr = (this.getDay() + 6) % 7; // Set the target to the thursday of this week so the // target date is in the right year target.setDate(target.getDate() - dayNr + 3); // ISO 8601 states that week 1 is the week with january 4th in it var jan4 = new Date(target.getFullYear(), 0, 4); // Number of days between target date and january 4th var dayDiff = (target - jan4) / 86400000; if(new Date(target.getFullYear(), 0, 1).getDay() < 5) { // Calculate week number: Week 1 (january 4th) plus the // number of weeks between target date and january 4th return 1 + Math.ceil(dayDiff / 7); } else { // jan 4th is on the next week (so next week is week 1) return Math.ceil(dayDiff / 7); } }; </code></pre> </answer> <answer tick="false" vote="-1"> <p><a href="https://stackoverflow.com/users/1145706/martin-schilliger">Martin Schillinger</a> 的版本似乎是严格正确的版本。</p> <p>因为我知道我只需要它在工作日正常工作,所以我使用了这个更简单的表格,基于我在网上找到的东西,不记得在哪里:</p> <pre><code>ISOWeekday = (0 == InputDate.getDay()) ? 7 : InputDate.getDay(); ISOCalendarWeek = Math.floor( ( ((InputDate.getTime() - (new Date(InputDate.getFullYear(),0,1)).getTime()) / 86400000) - ISOWeekday + 10) / 7 ); </code></pre> <p>它在一月初的那些属于上一年最后一周的日子里失败了(在这些情况下它产生 CW = 0),但对于其他一切都是正确的。</p> </answer> </body></html>
我的服务中获取每月最后一天的功能在哪里? DateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); 日期 date = format.parse(stringDate); 钙...
如何计算一个月内有多少个星期二? 使用calender.set我们可以设置特定的月份,然后如何计算该月的星期一、星期二等的数量? 代码是: 公共静态