java.util.Calendar getActualMinimum()方法

java.util.Calendar.getActualMinimum() 方法返回一个整数值,该整数值是作为参数传递给getActualMinimum()方法的日历字段的最小可能值。例如,DATE字段的最小值为1,而MONTH字段的最小值为0。

1 语法

public int getActualMinimum(int field)  

2 参数

field:像MONTH,HOUR,DAY_OF_MONTH等日历字段

3 返回值

返回一个整数值,该整数值是作为参数传递的字段的最大值。

4 示例1 

package com.yiidian;

/**
 * 一点教程网: http://www.yiidian.com
 */
/**
 * java.util.Calendar getActualMinimum()方法的例子
 */
import java.util.*;  
public class CalendargetactualminimumExample1 {  
   public static void main(String[] args) {  
  // create a calendar  
      Calendar cal = Calendar.getInstance();  
  // return the minimum value that Year field can have.  
      int year = cal.getActualMinimum(Calendar.YEAR);  
      System.out.println("Minimum year value:" + year);  
      // return the minimum value that Year field can have.  
      int Month = cal.getActualMinimum(Calendar.MONTH);  
      System.out.println("Minimum Month value:" + Month);  
      // return the minimum value that day field can have.  
      int day = cal.getActualMinimum(Calendar.DAY_OF_WEEK);  
      System.out.println("Minimum Day value:" + year);  
    
   }  
} 

输出结果为:

Minimum year value:1
Minimum Month value:0
Minimum Day value:1

5 示例2

package com.yiidian;

/**
 * 一点教程网: http://www.yiidian.com
 */
/**
 * java.util.Calendar getActualMinimum()方法的例子
 */
import java.util.*;  
public class CalendargetactualminimumExample2 {  
   public static void main(String[] args) {  
      // create a calendar  
      Calendar cal = Calendar.getInstance();  
      // get minimum HOUR field value and assign it in hour variable  
      int Hour = cal.getActualMinimum(Calendar.HOUR);  
      System.out.println("Minimum HOUR value is:" + Hour);  
      // get minimum HOUR field value and assign it in hour variable  
      int Minute = cal.getActualMinimum(Calendar.MINUTE);  
      System.out.println("Minimum Minute value is:" + Minute);  
      // get minimum HOUR field value and assign it in hour variable  
      int Second = cal.getActualMinimum(Calendar.SECOND);  
      System.out.println("Minimum Second value is:" + Second);  
     
   }  
}  

输出结果为:

Minimum HOUR value is:0
Minimum Minute value is:0
Minimum Second value is:0

6 示例3

package com.yiidian;

/**
 * 一点教程网: http://www.yiidian.com
 */
/**
 * java.util.Calendar getActualMinimum()方法的例子
 */
import java.util.*;  
public class CalendargetactualminimumExample3 {  
   public static void main(String[] args) {  
      // create a calendar  
      Calendar cal = Calendar.getInstance();  
      // get minimum value of passed fields and stores in corresponding parameter.  
      int day1 = cal.getActualMinimum(Calendar.DAY_OF_WEEK_IN_MONTH);  
      System.out.println("Minimum  value for DAY_OF_WEEK_IN_MONTH  is :" + day1);  
      int day2 = cal.getActualMinimum(Calendar.DAY_OF_MONTH);  
        System.out.println("Minimum  value for DAY_OF_MONTH is :" + day2);  
        int dt = cal.getActualMinimum(Calendar.DATE);  
        System.out.println("Minimum value for  DATE is :" + dt);  
   }  
}  

输出结果为:

Minimum  value for DAY_OF_WEEK_IN_MONTH  is :1
Minimum  value for DAY_OF_MONTH is :1
Minimum value for  DATE is :1

 

热门文章

优秀文章