java.util.Calendar setMinimalDaysInFirstWeek()方法

java.util.Calendar.setMinimalDaysInFirstWeek() 方法设置在一年中第一个星期所需最少天数。

1 语法

public void setMinimalDaysInFirstWeek(int value)

2 参数

value:本年的第一个星期所需的给定最少天数。

3 返回值

4 示例1 

package com.yiidian;

/**
 * 一点教程网: http://www.yiidian.com
 */
/**
 * java.util.Calendar setMinimalDaysInFirstWeek()方法的例子
 */
import java.util.*;

public class CalendarDemo {

   public static void main(String[] args) {

      // create a calendar
      Calendar cal = Calendar.getInstance();

      // get what is the minimal days required in the first week
      int min = cal.getMinimalDaysInFirstWeek();
      System.out.println("Minimal Days in Week: " + min);

      // set the minimal days required in the first week
      cal.setMinimalDaysInFirstWeek(2);

      // print the result
      min = cal.getMinimalDaysInFirstWeek();
      System.out.println("Minimal Days in Week: " + min);
   }
}

输出结果为:

Minimal Days in Week: 1
Minimal Days in Week: 2

 

热门文章

优秀文章