java.util.GregorianCalendar.getMinimum()方法是Java中的内置函数,它返回作为参数传递给该函数的特定日历字段的最小值。对于任何可能的时间值,它也是get()方法返回的最小值,同时考虑getFirstDayOfWeek(),getMinimalDaysInFirstWeek(),getGregorianChange()和getTimeZone()方法的当前值。
用法:
public int getMinimum(int calendarfield)
参数:该函数接受一个整数类型的强制性参数calendarfield,该函数的该GregorianCalender实例的最小值将返回。
返回值:
此方法为此GregorianCalender实例返回指定日历字段的最小值。
例子:
Input : DAY_OF_MONTH Output : 1 Input : WEEK_OF_MONTH Output : 0
以下程序说明了java.util.GregorianCalendar.getMinimum()函数的用法:
示例1:
// Java Program to illustrate getMinimum() function
// GregorianCalender
import java.io.*;
import java.util.*;
class GFG {
public static void main(String[] args) {
// Create a new calendar
GregorianCalendar cal = (GregorianCalendar)
GregorianCalendar.getInstance();
// Display the current date and time
System.out.println("Current Date and Time : "
+ cal.getTime());
// Display minimum for WEEK_OF_MONTH
int minm = cal.getMinimum(GregorianCalendar.WEEK_OF_MONTH);
System.out.println("Minimum for WEEK_OF_MONTH field :"
+ minm);
// Display minimum for DAY_OF_MONTH
minm = cal.getMinimum(GregorianCalendar.DAY_OF_MONTH);
System.out.println("Minimum for DAY_OF_MONTH field:"
+ minm);
}
}
输出:
Current Date and Time : Fri Jul 27 11:40:24 UTC 2018 Minimum for WEEK_OF_MONTH field :0 Minimum for DAY_OF_MONTH field:1
示例2:
// Java Program to illustrate getMinimum() function
// GregorianCalender
import java.io.*;
import java.util.*;
class GFG {
public static void main(String[] args) {
// Create a new calendar
GregorianCalendar cal = (GregorianCalendar)
GregorianCalendar.getInstance();
// Display the current date and time
System.out.println("Current Date and Time : "
+ cal.getTime());
// Display minimum for YEAR
int minm = cal.getMinimum(GregorianCalendar.YEAR);
System.out.println("Minimum for YEAR field :"
+ minm);
// Display minimum for HOUR_OF_DAY
minm = cal.getMinimum(GregorianCalendar.HOUR_OF_DAY);
System.out.println("Minimum for HOUR_OF_DAY field :"
+ minm);
}
}
输出:
Current Date and Time : Fri Jul 27 11:40:28 UTC 2018 Minimum for YEAR field :1 Minimum for HOUR_OF_DAY field :0
参考:https://docs.oracle.com/javase/7/docs/api/java/util/GregorianCalendar.html#getMinimum()
相关用法
- Java ValueRange getMinimum()用法及代码示例
- Java Calendar getMinimum()用法及代码示例
- Java GregorianCalendar add()用法及代码示例
- Java GregorianCalendar clone()用法及代码示例
- Java GregorianCalendar equals()用法及代码示例
- Java GregorianCalendar hashCode()用法及代码示例
- Java GregorianCalendar getMaximum()用法及代码示例
- Java GregorianCalendar getGreatestMinimum()用法及代码示例
- Java GregorianCalendar getLeastMaximum()用法及代码示例
- Java GregorianCalendar isLeapYear()用法及代码示例
- Java GregorianCalendar getTimeZone()用法及代码示例
- Java GregorianCalendar setTimeZone()用法及代码示例
- Java Java.util.Collections.rotate()用法及代码示例
注:本文由纯净天空筛选整理自RICHIK BHATTACHARJEE大神的英文原创作品 GregorianCalendar getMinimum() Method in Java。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。