當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。