java 獲取當前是本年、本月、本季度 第幾周


import java.util.Calendar;
public class Date6 {
    public static void main(String[] args)
    {
        Calendar c = Calendar.getInstance();
        int month=c.get(c.WEEK_OF_MONTH);
        int week = c.get(c.WEEK_OF_YEAR);
        String quarter="";
        int m=c.get(c.MONTH);
        if (m >= 1 && m == 3) {
            quarter = "1";
        }
        else if (m >= 4 && m <= 6) {
            quarter = "2";
        }
        else if (m >= 7 && m <= 9) {
            quarter = "3";
        }
        else {
            quarter = "4";
        }
        System.out.println("今天是今年的第" + week + "周;");
        System.out.println("今天是今月的第" + month + "周;");
        System.out.println("當前季度為"+quarter+"季度");

    }
}

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM