當前位置: 首頁>>代碼示例>>Java>>正文


Java Calendar.getActualMaximum方法代碼示例

本文整理匯總了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();
}
 
開發者ID:ApplikeySolutions,項目名稱:CosmoCalendar,代碼行數:18,代碼來源:DateUtils.java

示例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();
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:36,代碼來源:TimeUtils.java

示例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);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:9,代碼來源:DatePickerDialog.java

示例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);
}
 
開發者ID:ser316asu,項目名稱:SER316-Dresden,代碼行數:22,代碼來源:JNCalendar.java

示例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);
}
 
開發者ID:ser316asu,項目名稱:SER316-Ingolstadt,代碼行數:19,代碼來源:JNCalendar.java

示例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;
}
 
開發者ID:quickhybrid,項目名稱:quickhybrid-android,代碼行數:9,代碼來源:DateUtil.java

示例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;

}
 
開發者ID:ser316asu,項目名稱:Reinickendorf_SER316,代碼行數:14,代碼來源:CalendarDate.java

示例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();
}
 
開發者ID:warlock-china,項目名稱:azeroth,代碼行數:11,代碼來源:DateUtils.java

示例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;
        }
    }
}
 
開發者ID:ztan5,項目名稱:TechnicalAnalysisTool,代碼行數:39,代碼來源:DateUtil.java

示例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;
}
 
開發者ID:lutvie72,項目名稱:RackMonthPicker,代碼行數:8,代碼來源:MonthAdapter.java

示例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();
    }
}
 
開發者ID:nichbar,項目名稱:MonthView,代碼行數:20,代碼來源:MonthView.java

示例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);
}
 
開發者ID:timtu,項目名稱:spring-boot-wechat,代碼行數:6,代碼來源:DateUtils.java

示例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);
}
 
開發者ID:timtu,項目名稱:spring-boot-wechat,代碼行數:6,代碼來源:DateUtils.java

示例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);
}
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:6,代碼來源:MonthlyViewActivity.java

示例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;
}
 
開發者ID:quickhybrid,項目名稱:quickhybrid-android,代碼行數:7,代碼來源:DateUtil.java


注:本文中的java.util.Calendar.getActualMaximum方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。