当前位置: 首页>>代码示例>>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;未经允许,请勿转载。