本文整理汇总了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;
}