久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

根據(jù)周開(kāi)始獲取每月的周數(shù)

Get weeks of the month depending on week start(根據(jù)周開(kāi)始獲取每月的周數(shù))
本文介紹了根據(jù)周開(kāi)始獲取每月的周數(shù)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

限時(shí)送ChatGPT賬號(hào)..

我在我的應(yīng)用程序中使用自定義日歷.我讓用戶(hù)可以選擇一周的第一天,這可能是:Saturday, Sunday, Monday

I am using a custom calendar in my app. I have given the users option to select the first day of the week which could be: Saturday, Sunday, Monday

我想獲取一個(gè)月中的周數(shù) - 取決于一周的開(kāi)始時(shí)間,覆蓋周開(kāi)始的默認(rèn)值 - Sunday.

I want to get the number of weeks in a month - depending on when the week starts, overriding the default value of week start - Sunday.

代碼:

public int getWeeksOfMonth(int year, int month) { 
    Calendar calendar = Calendar.getInstance(); 
    calendar.set(Calendar.MONTH, month-1);
    calendar.set(Calendar.YEAR, year);
    int numOfWeeksInMonth = calendar.getActualMaximum(Calendar.WEEK_OF_MONTH); 

    return numOfWeeksInMonth;
}

推薦答案

試試

calendar.setFirstDayOfWeek(Calendar.MONDAY); //sets first day to monday, for example.

在您的情況下,您可能想要這樣做:

In your case you might want to do this:

public int getWeeksOfMonth(int year, int month, int weekStart) { 
    Calendar calendar = Calendar.getInstance();  
    calendar.set(Calendar.MONTH, month-1);
    calendar.set(Calendar.YEAR, year);
    calendar.setFirstDayOfWeek(weekStart);
    int numOfWeeksInMonth = calendar.getActualMaximum(Calendar.WEEK_OF_MONTH); 

    return numOfWeeksInMonth;
}

并用一行如

int weeks = getWeeksOfMonth(2012, 5, Calendar.WEDNESDAY);

這篇關(guān)于根據(jù)周開(kāi)始獲取每月的周數(shù)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時(shí)間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉(zhuǎn)換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉(zhuǎn)換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當(dāng)前星期幾的值)
主站蜘蛛池模板: 色中文在线 | 国产欧美在线 | 久草青青 | 久草综合在线 | 国产成人精品视频在线观看 | 国产色黄 | 国产精品久久久久久久久久久久久 | 精品一区二区三区在线观看国产 | 久久精品中文字幕 | 97超碰人人| 天天久久 | 国产精品久久国产愉拍 | 粉嫩一区二区三区四区公司1 | 精品视频免费 | 极品销魂美女一区二区 | 成人在线观看免费 | 成人免费视频 | 久久久久久国产精品 | 日韩久久久久 | 午夜影院在线观看 | 91 在线 | 国产特级毛片 | 91在线视频在线观看 | 激情婷婷成人 | 国产成人综合一区二区三区 | 亚洲福利一区 | 色综合99 | 91精品国产综合久久久久久蜜臀 | 男人天堂色 | 国产一区亚洲 | 亚洲一区二区三区高清 | 欧美国产精品一区二区三区 | 亚洲综合色站 | 一区二区三区精品 | 亚洲精品久久视频 | 激情毛片 | 亚洲国产高清高潮精品美女 | 久久久久久久一区 | 成人在线视频免费观看 | 亚洲一二三区免费 | 一级片在线免费播放 |