当前位置: 首页>>代码示例>>Java>>正文


Java Calendar.roll方法代码示例

本文整理汇总了Java中java.util.Calendar.roll方法的典型用法代码示例。如果您正苦于以下问题:Java Calendar.roll方法的具体用法?Java Calendar.roll怎么用?Java Calendar.roll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Calendar的用法示例。


在下文中一共展示了Calendar.roll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getItem

import java.util.Calendar; //导入方法依赖的package包/类
public View getItem(int index, View cachedView, ViewGroup parent) {
    int day = index - 30;
    Calendar newCalendar = (Calendar) DietDatePicker.this.calendar.clone();
    newCalendar.roll(6, day);
    View view = super.getItem(index, cachedView, parent);
    ((TextView) view.findViewById(R.id.weekday)).setText(new SimpleDateFormat("EEE")
            .format(newCalendar.getTime()));
    TextView monthday = (TextView) view.findViewById(R.id.monthday);
    if (day == 0) {
        monthday.setText(DateHelper.format(newCalendar.getTime()) + SocializeConstants
                .OP_OPEN_PAREN + DietDatePicker.this.ctx.getString(R.string.a9h) +
                SocializeConstants.OP_CLOSE_PAREN);
        monthday.setTextColor(-16776976);
    } else {
        monthday.setText(DateHelper.format(newCalendar.getTime()));
        monthday.setTextColor(-15658735);
    }
    return view;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:DietDatePicker.java

示例2: forward

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * 使指定日期向前走一天,变成“明天”的日期
 *
 * @param cal 处理日期
 */
public void forward(Calendar cal) {
    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH);//0到11
    int day = cal.get(Calendar.DAY_OF_MONTH);
    int days = getDaysOfMonth(year, month + 1);
    if (day == days) {//如果是本月最后一天,还要判断年份是不是要向前滚
        if (month == 11) {//如果是12月份,年份要向前滚
            cal.roll(Calendar.YEAR, true);
            cal.set(Calendar.MONTH, 0);//月份,第一月是0
            cal.set(Calendar.DAY_OF_MONTH, 1);
        } else {//如果不是12月份
            cal.roll(Calendar.MONTH, true);
            cal.set(Calendar.DAY_OF_MONTH, 1);
        }
    } else {
        cal.roll(Calendar.DAY_OF_MONTH, 1);//如果是月内,直接天数加1
    }
}
 
开发者ID:jopenbox,项目名称:android-lite-utils,代码行数:24,代码来源:DateUtils.java

示例3: getPreviousMonthEnd

import java.util.Calendar; //导入方法依赖的package包/类
public String getPreviousMonthEnd()
{
    String str = "";
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    
    Calendar lastDate = Calendar.getInstance();
    lastDate.add(Calendar.MONTH, -1);// 减一个月
    lastDate.set(Calendar.DATE, 1);// 把日期设置为当月第一天
    lastDate.roll(Calendar.DATE, -1);// 日期回滚一天,也就是本月最后一天
    str = sdf.format(lastDate.getTime());
    return str;
}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:13,代码来源:MIP_CalendarUtil2.java

示例4: findBooks

import java.util.Calendar; //导入方法依赖的package包/类
public List<Book> findBooks(final Date from, final Date to) {
    Calendar end = Calendar.getInstance();
    end.setTime(to);
    end.roll(Calendar.YEAR, 1);

    return store.stream().filter(book -> {
        return from.before(book.getPublished())
                && end.getTime().after(book.getPublished());
    }).sorted(Comparator.comparing(Book::getPublished).reversed())
            .collect(Collectors.toList());
}
 
开发者ID:bonigarcia,项目名称:mastering-junit5,代码行数:12,代码来源:Library.java

示例5: getMonthDays

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * 获取指定年月的天数
 * @param year 指定公历年
 * @param month 指定公历月份
 * @return 该年月的天数
 */
public static int getMonthDays(int year, int month) {
    Calendar tmpCalendar = Calendar.getInstance();
    tmpCalendar.set(Calendar.YEAR, year);
    tmpCalendar.set(Calendar.MONTH, month);
    tmpCalendar.set(Calendar.DATE, 1);
    tmpCalendar.roll(Calendar.DATE, -1);

    return tmpCalendar.get(Calendar.DATE);
}
 
开发者ID:mainh,项目名称:MainCalendar,代码行数:16,代码来源:DateUtil.java

示例6: getCurrentMonthDay

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * 获取当月的 天数
 */
public static int getCurrentMonthDay() {

    Calendar a = Calendar.getInstance();
    a.set(Calendar.DATE,
          1);
    a.roll(Calendar.DATE,
           -1);
    int maxDate = a.get(Calendar.DATE);
    return maxDate;
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:14,代码来源:DateUtil.java

示例7: getMonthLastDay

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * 得到指定月的天数
 * */
public static int getMonthLastDay(int year, int month)
{
	Calendar a = Calendar.getInstance();
	a.set(Calendar.YEAR, year);
	a.set(Calendar.MONTH, month - 1);
	a.set(Calendar.DATE, 1);//把日期设置为当月第一天
	a.roll(Calendar.DATE, -1);//日期回滚一天,也就是最后一天
	int maxDate = a.get(Calendar.DATE);
	return maxDate;
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:14,代码来源:DateKit.java

示例8: getNextMonthEnd

import java.util.Calendar; //导入方法依赖的package包/类
public static String getNextMonthEnd() {
    String str = "";
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    Calendar lastDate = Calendar.getInstance();
    lastDate.add(Calendar.MONTH, 1);// 加一个月
    lastDate.set(Calendar.DATE, 1);// 把日期设置为当月第一天
    lastDate.roll(Calendar.DATE, -1);// 日期回滚一天,也就是本月最后一天
    str = sdf.format(lastDate.getTime());
    return str;
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:12,代码来源:DateUtil.java

示例9: ArrNumMonth

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * Is the method invoked to calculate the number of months in the log (Variable)
 */
private void ArrNumMonth() {
	ArrMonth = new Vector<double[]>();
	double i[];
	Calendar cal = Calendar.getInstance();
	Calendar cal2 = Calendar.getInstance();
	cal.setTimeInMillis((long) v.getValue(0));
	int y = 0;
	boolean k = false;
	int z = 0;
	while (z < v.Size()) {

		cal2.setTimeInMillis((long) v.getValue(z));
		if (cal.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal.get(Calendar.MONTH) == cal2.get(Calendar.MONTH)) {
			y++;
		} else {
			k = false;
			i = new double[2];
			i[0] = cal.getTimeInMillis();
			i[1] = y;
			ArrMonth.addElement(i);
			cal.roll(Calendar.MONTH, true);
			if (cal.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal.get(Calendar.MONTH) == cal2.get(Calendar.MONTH)) {
				y = 1;

			} else {
				y = 0;
				k = false;
			}
		}
		if (k != true) {
			z++;
		}
	}
	i = new double[2];
	i[0] = cal.getTimeInMillis();
	i[1] = y;
	ArrMonth.addElement(i);

}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:43,代码来源:GraphArrivalPanel.java

示例10: getMonthLastDay

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * 得到指定月的天数
 */
public static int getMonthLastDay(int year, int month) {
    Calendar a = Calendar.getInstance();
    a.set(Calendar.YEAR, year);
    a.set(Calendar.MONTH, month - 1);
    a.set(Calendar.DATE, 1);// 把日期设置为当月第一天
    a.roll(Calendar.DATE, -1);// 日期回滚一天,也就是最后一天
    int maxDate = a.get(Calendar.DATE);
    return maxDate;
}
 
开发者ID:quickhybrid,项目名称:quickhybrid-android,代码行数:13,代码来源:DateUtil.java

示例11: tomorrow

import java.util.Calendar; //导入方法依赖的package包/类
public static CalendarDate tomorrow() {
  Calendar cal = Calendar.getInstance();
  cal.roll(Calendar.DATE, true);;
  return new CalendarDate(cal);
}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:6,代码来源:TagTest.java

示例12: ArrNumHour

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * Is the method invoked to calculate the number of hours in the log (Variable)
 */
private void ArrNumHour() {
	ArrHour = new Vector<double[]>();
	double i[];
	Calendar cal = Calendar.getInstance();
	cal.setTime(new Date((long) v.getValue(0)));
	Calendar cal2 = Calendar.getInstance();
	int y = 0;
	int z = 0;
	boolean k = false;
	while (z < v.Size()) {
		cal2.setTimeInMillis((long) v.getValue(z));
		if (cal.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal.get(Calendar.MONTH) == cal2.get(Calendar.MONTH)
				&& cal.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR)
				&& cal.get(Calendar.HOUR_OF_DAY) == cal2.get(Calendar.HOUR_OF_DAY)) {
			y++;
		} else {
			k = false;
			i = new double[2];
			i[0] = cal.getTimeInMillis();
			i[1] = y;
			ArrHour.addElement(i);

			if (cal.get(Calendar.HOUR_OF_DAY) == 23) {
				cal.roll(Calendar.DAY_OF_YEAR, true);
			}
			cal.roll(Calendar.HOUR_OF_DAY, true);
			if (cal.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal.get(Calendar.MONTH) == cal2.get(Calendar.MONTH)
					&& cal.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR)
					&& cal.get(Calendar.HOUR_OF_DAY) == cal2.get(Calendar.HOUR_OF_DAY)) {
				y = 1;
			} else {
				y = 0;
				k = true;
			}
		}
		if (k != true) {
			z++;
		}

	}
	i = new double[2];
	i[0] = cal.getTimeInMillis();
	i[1] = y;
	ArrHour.addElement(i);

}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:50,代码来源:GraphArrivalPanel.java

示例13: ArrNumMinute

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * Is the method invoked to calculate the number of minutes in the log (Variable)
 */
private void ArrNumMinute() {
	ArrMinute = new Vector<double[]>();
	double i[];
	Calendar cal = Calendar.getInstance();
	cal.setTime(new Date((long) v.getValue(0)));
	Calendar cal2 = Calendar.getInstance();
	int y = 0;
	boolean k = false;
	int z = 0;
	cal2.setTimeInMillis((long) v.getValue(z));
	while (z < v.Size()) {
		if (cal.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal.get(Calendar.MONTH) == cal2.get(Calendar.MONTH)
				&& cal.get(Calendar.DATE) == cal2.get(Calendar.DATE) && cal.get(Calendar.HOUR_OF_DAY) == cal2.get(Calendar.HOUR_OF_DAY)
				&& cal.get(Calendar.MINUTE) == cal2.get(Calendar.MINUTE)) {
			y++;
		} else {
			k = false;
			i = new double[2];
			i[0] = cal.getTimeInMillis();
			i[1] = y;
			ArrMinute.addElement(i);
			if (cal.get(Calendar.MINUTE) == 59 && cal.get(Calendar.HOUR_OF_DAY) != 23) {
				cal.roll(Calendar.HOUR_OF_DAY, true);
			}
			if (cal.get(Calendar.MINUTE) == 59 && cal.get(Calendar.HOUR_OF_DAY) == 23) {
				cal.roll(Calendar.HOUR_OF_DAY, true);
				cal.roll(Calendar.DAY_OF_YEAR, true);
			}
			cal.roll(Calendar.MINUTE, true);
			if (cal.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal.get(Calendar.MONTH) == cal2.get(Calendar.MONTH)
					&& cal.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR)
					&& cal.get(Calendar.HOUR_OF_DAY) == cal2.get(Calendar.HOUR_OF_DAY) && cal.get(Calendar.MINUTE) == cal2.get(Calendar.MINUTE)) {
				y = 1;
			} else {
				y = 0;
				k = true;
			}
		}
		if (k != true) {
			z++;
			if (z < v.Size()) {
				cal2.setTimeInMillis((long) v.getValue(z));
			}
		}
	}
	i = new double[2];
	i[0] = cal.getTimeInMillis();
	i[1] = y;
	ArrMinute.addElement(i);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:54,代码来源:GraphArrivalPanel.java

示例14: yesterday

import java.util.Calendar; //导入方法依赖的package包/类
public static CalendarDate yesterday() {
    Calendar cal = Calendar.getInstance();
    cal.roll(Calendar.DATE, false);
    return new CalendarDate(cal);
}
 
开发者ID:ser316asu,项目名称:Reinickendorf_SER316,代码行数:6,代码来源:CalendarDate.java

示例15: tomorrow

import java.util.Calendar; //导入方法依赖的package包/类
public static CalendarDate tomorrow() {
    Calendar cal = Calendar.getInstance();
    cal.roll(Calendar.DATE, true);
    return new CalendarDate(cal);
}
 
开发者ID:ser316asu,项目名称:SER316-Ingolstadt,代码行数:6,代码来源:CalendarDate.java


注:本文中的java.util.Calendar.roll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。