本文整理匯總了Java中java.util.Calendar.getActualMaximum方法的典型用法代碼示例。如果您正苦於以下問題:Java Calendar.getActualMaximum方法的具體用法?Java Calendar.getActualMaximum怎麽用?Java Calendar.getActualMaximum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.Calendar
的用法示例。
在下文中一共展示了Calendar.getActualMaximum方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getLastDayOfWeek
import java.util.Calendar; //導入方法依賴的package包/類
public static Date getLastDayOfWeek(@Nullable Date date) {
Calendar calendar = Calendar.getInstance();
if (date != null) {
calendar.setTime(date);
}
calendar.clear(Calendar.HOUR_OF_DAY);
calendar.clear(Calendar.HOUR);
if (calendar.get(Calendar.DAY_OF_MONTH) == calendar.getActualMaximum(Calendar.DAY_OF_MONTH)
&& calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
return calendar.getTime();
}
calendar.set(Calendar.DAY_OF_WEEK, calendar.getActualMaximum(Calendar.DAY_OF_WEEK));
while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
calendar.add(Calendar.DATE, 1);
}
return calendar.getTime();
}
示例2: getSomeMonthsBefore
import java.util.Calendar; //導入方法依賴的package包/類
/**
* 獲取本日的n個月前的日期,如本日=2015-03-01,n=3,則輸出2014-12-01
*
* @param n
* @return
*/
public static Date getSomeMonthsBefore(int n) {
Calendar cl = Calendar.getInstance();
cl.set(Calendar.HOUR_OF_DAY, 0);
cl.set(Calendar.MINUTE, 0);
cl.set(Calendar.SECOND, 0);
cl.set(Calendar.MILLISECOND, 0);
int year = cl.get(Calendar.YEAR);
int month = cl.get(Calendar.MONTH);
int day = cl.get(Calendar.DAY_OF_MONTH);
int by = n / 12;
int bm = n % 12;
if (by > 0) {
year -= by;
}
if (bm > month) {
year--;
}
month = (12 + month - bm) % 12;
cl.set(Calendar.YEAR, year);
cl.set(Calendar.MONTH, month);
cl.set(Calendar.DAY_OF_MONTH, 1);
if (day > cl.getActualMaximum(Calendar.DAY_OF_MONTH)) {//cl為n個月前的1號,如果該月的最大日數比現在的日數小,則取當月的最大日數
cl.set(Calendar.DAY_OF_MONTH, cl.getActualMaximum(Calendar.DAY_OF_MONTH));
} else {
cl.set(Calendar.DAY_OF_MONTH, day);
}
return cl.getTime();
}
示例3: adjustDayInMonthIfNeeded
import java.util.Calendar; //導入方法依賴的package包/類
private void adjustDayInMonthIfNeeded(Calendar calendar) {
int day = calendar.get(5);
int daysInMonth = calendar.getActualMaximum(5);
if (day > daysInMonth) {
calendar.set(5, daysInMonth);
}
setToNearestDate(calendar);
}
示例4: setCalendarParameters
import java.util.Calendar; //導入方法依賴的package包/類
/**
* Builds calendar based on the first and last day of the week.
*/
void setCalendarParameters() {
int d = 1;
Calendar cal = _date.getCalendar();
if (Configuration.get("FIRST_DAY_OF_WEEK").equals("mon")) {
cal.setFirstDayOfWeek(Calendar.MONDAY);
d = 2;
} else
cal.setFirstDayOfWeek(Calendar.SUNDAY);
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.getTime();
firstDay = cal.get(Calendar.DAY_OF_WEEK) - d;
if (firstDay == -1)
firstDay = 6;
daysInMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
}
示例5: setCalendarParameters
import java.util.Calendar; //導入方法依賴的package包/類
void setCalendarParameters() {
int d = 1;
Calendar cal = _date.getCalendar();
if (Configuration.get("FIRST_DAY_OF_WEEK").equals("mon")) {
cal.setFirstDayOfWeek(Calendar.MONDAY);
d = 2;
} else
cal.setFirstDayOfWeek(Calendar.SUNDAY);
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.getTime();
firstDay = cal.get(Calendar.DAY_OF_WEEK) - d;
if (firstDay == -1)
firstDay = 6;
daysInMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
}
示例6: getDaysOfYM
import java.util.Calendar; //導入方法依賴的package包/類
public static int getDaysOfYM(int year, int month) {
Calendar time = Calendar.getInstance();
time.clear();
time.set(Calendar.YEAR, year);
time.set(Calendar.MONTH, month - 1);
int day = time.getActualMaximum(Calendar.DAY_OF_MONTH);
return day;
}
示例7: CalendarDate
import java.util.Calendar; //導入方法依賴的package包/類
public CalendarDate(int day, int month, int year) {
_year = year;
_month = month;
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, _year);
cal.set(Calendar.MONTH, _month);cal.getTime();
int dmax = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
if (day <= dmax)
_day = day;
else
_day = dmax;
}
示例8: lastDayOfMonth
import java.util.Calendar; //導入方法依賴的package包/類
/**
* 返回傳入時間月份的最後一天
* */
public static Date lastDayOfMonth(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int value = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
cal.set(Calendar.DAY_OF_MONTH, value);
return cal.getTime();
}
示例9: isLastDayofYear
import java.util.Calendar; //導入方法依賴的package包/類
/**
* Return if the date is the last Day of the year
* @param calendar Calendar object in query
* @param countryName Country Name
* @return true if it is otherwise return false
*/
public static boolean isLastDayofYear(Calendar calendar, String countryName){
Calendar local = (Calendar)calendar.clone();
if(local == null)
return false;
if (isWeekend(local)){
return false;
}
if (isPublicHoliday(local, countryName)){
return false;
}
int maxDayOfYear = local.getActualMaximum(Calendar.DAY_OF_YEAR);
int dayOfYearh = local.get(Calendar.DAY_OF_YEAR);
if (dayOfYearh == maxDayOfYear){
return true;
} else {
while(local.get(Calendar.DAY_OF_YEAR) != maxDayOfYear){
local.add(Calendar.DAY_OF_YEAR, 1);
if (!isWeekend(local) && !isPublicHoliday(local, countryName)){
return false;
}
}
if (isWeekend(local) || isPublicHoliday(local, countryName)){
return true;
}else{
return false;
}
}
}
示例10: getEndDate
import java.util.Calendar; //導入方法依賴的package包/類
public int getEndDate() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.MONTH, selectedItem + 1);
cal.set(Calendar.DAY_OF_MONTH, selectedItem + 1);
int maxDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
return maxDay;
}
示例11: setCalendar
import java.util.Calendar; //導入方法依賴的package包/類
/**
* Set the calendar.
* This calendar instance is the fundamental of this MonthView class.
*
* @param calendar the calendar you want this MonthView to show.
*/
public void setCalendar(Calendar calendar) {
if (mCalendar != calendar) {
mCalendar = calendar;
Calendar preCalendar = (Calendar) mCalendar.clone();
preCalendar.add(Calendar.MONTH, -1);
mDayOffset = getDayOffset();
mMonthDayCount = mCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
mPreMonthDayCount = preCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
postInvalidate();
}
}
示例12: getTotalDaysOfYear
import java.util.Calendar; //導入方法依賴的package包/類
public static int getTotalDaysOfYear(Date date) {
Calendar calendar = Calendar.getInstance(local);
calendar.setTime(date);
return calendar.getActualMaximum(6);
}
示例13: getTotalDaysOfMonth
import java.util.Calendar; //導入方法依賴的package包/類
public static int getTotalDaysOfMonth(Date date) {
Calendar calendar = Calendar.getInstance(local);
calendar.setTime(date);
return calendar.getActualMaximum(5);
}
示例14: getLastDayOfMonth
import java.util.Calendar; //導入方法依賴的package包/類
private int getLastDayOfMonth(int month, int year) {
Calendar calCurr = GregorianCalendar.getInstance();
calCurr.set(year, month-1, 1); // Months are 0 to 11
return calCurr.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);
}
示例15: getDayNumsOfMonth
import java.util.Calendar; //導入方法依賴的package包/類
public static int getDayNumsOfMonth(Date date) {
Calendar time = Calendar.getInstance();
time.setTime(date);
int day = time.getActualMaximum(Calendar.DAY_OF_MONTH);
return day;
}