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


Java CalendarUtil.addMonthsToDate方法代码示例

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


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

示例1: addMonthsToDateSafe

import com.google.gwt.user.datepicker.client.CalendarUtil; //导入方法依赖的package包/类
/**
 * it's behavior is like Calendar's addmonth(), but it works fine
 * 
 * @param date
 * @param delta
 */
@SuppressWarnings("deprecation")
public static void addMonthsToDateSafe(Date date, int delta) {
    int h = date.getHours();
    int m = date.getMinutes();
    int s = date.getSeconds();
    int d = date.getDate() - 1;

    CalendarUtil.setToFirstDayOfMonth(date);
    CalendarUtil.addMonthsToDate(date, delta);

    int month = date.getMonth();

    while (d > 0 && date.getMonth() == month) {
        CalendarUtil.addDaysToDate(date, 1);
        d--;
    }

    if (date.getMonth() != month) {
        CalendarUtil.addDaysToDate(date, -1);
    }

    date.setHours(h);
    date.setMinutes(m);
    date.setSeconds(s);
}
 
开发者ID:inepex,项目名称:ineform,代码行数:32,代码来源:IneDateGWT.java

示例2: stepForward

import com.google.gwt.user.datepicker.client.CalendarUtil; //导入方法依赖的package包/类
/**
 * 
 * @param prec
 * @param count
 *            if negative, it is a "step backwards"
 */
public void stepForward(Precision prec, int count) {
    switch (prec) {
        case YMD_HM:
            date.setTime(date.getTime() + MIN * count);
            return;

        case OOO_OM:
        case OOO_HM:
            date.setTime(date.getTime() + MIN * count);
            return;

        case OOO_HO:
            date.setTime(date.getTime() + MIN * 60 * count);
            return;

        case OOO_HMS:
            date.setTime(date.getTime() + SEC * count);
            return;

        case YMD_OO:
            CalendarUtil.addDaysToDate(date, count);
            return;

        case YMO_OO:
            addMonthsToDateSafe(date, count);
            return;

        case YOO_OO:
            CalendarUtil.addMonthsToDate(date, 12 * count);
            return;

        case OMO_OO:
            return;
    }

    throw new RuntimeException(
        "IneDateGWT: stepOneForward(): there is no case for: " + prec.toString());
}
 
开发者ID:inepex,项目名称:ineform,代码行数:45,代码来源:IneDateGWT.java

示例3: DateLocalizationExample

import com.google.gwt.user.datepicker.client.CalendarUtil; //导入方法依赖的package包/类
public DateLocalizationExample()
{
    super( "Date Localization" );

    DateLocalizationStrings strings = GWT.create( DateLocalizationStrings.class );
    this.label = new Label();
    this.label.setText( strings.defaultDaysMessage() );
    this.add(new Label(strings.selectString()));

    final DateLocalizationMessages messages = GWT.create( DateLocalizationMessages.class );

    DateBox dateBox = new DateBox();
    dateBox.setFormat( new DateBox.DefaultFormat( DateTimeFormat.getLongDateFormat()) );
    Date date = new Date();
    CalendarUtil.addMonthsToDate( date, -29 * 12 );
    dateBox.setValue( date );

    dateBox.addValueChangeHandler( new ValueChangeHandler<Date>() {

        public void onValueChange( ValueChangeEvent<Date> e )
        {
          long days = CalendarUtil.getDaysBetween(e.getValue(), new Date() );
          label.setText( messages.daysMessage( days ) );
        }
    });

    this.add( dateBox );
    this.add( label );
}
 
开发者ID:DavidWhitlock,项目名称:PortlandStateJava,代码行数:30,代码来源:DateLocalizationExample.java

示例4: lastDayOfMonth

import com.google.gwt.user.datepicker.client.CalendarUtil; //导入方法依赖的package包/类
private Date lastDayOfMonth(Date month) {
    Date lastDay = (Date) month.clone();
    CalendarUtil.addMonthsToDate(lastDay, 1);
    CalendarUtil.setToFirstDayOfMonth(lastDay);
    CalendarUtil.addDaysToDate(lastDay, -1);
    return justDay(lastDay);
}
 
开发者ID:vaadin,项目名称:touchkit,代码行数:8,代码来源:CalendarOverlay.java

示例5: redrawCalendarPicker

import com.google.gwt.user.datepicker.client.CalendarUtil; //导入方法依赖的package包/类
private void redrawCalendarPicker() {
	this.monthPicker.getStyle().setDisplay(Display.NONE);
	this.calendarTable.getStyle().clearDisplay();

	this.calendatBody.removeAllChildren();

	int firstDayOfWeek = InputDatePicker.DATE_TIME_FORMAT_INFO.firstDayOfTheWeek();
	int lastDayOfWeek = (firstDayOfWeek + InputDatePicker.DAYS_IN_WEEK) % InputDatePicker.DAYS_IN_WEEK;

	/* Display month */
	this.monthPickerButton.setInnerHTML(InputDatePicker.MONTH_YEAR_FORMAT.format(this.cursor)
		+ "<span class=\"caret\"></span>");

	Date lastMonth = new Date(this.cursor.getTime());
	CalendarUtil.addMonthsToDate(lastMonth, -1);
	this.pagePreviusMonthLi.setAttribute(InputDatePicker.ATTRIBUTE_DATA_CURSOR, InputDatePicker.ATTRIBUTE_DATE_FORMAT
		.format(lastMonth));
	this.pageTodayLi.setAttribute(InputDatePicker.ATTRIBUTE_DATA_CURSOR, InputDatePicker.ATTRIBUTE_DATE_FORMAT
		.format(this.today));
	Date nextMonth = new Date(this.cursor.getTime());
	CalendarUtil.addMonthsToDate(nextMonth, 1);
	this.pageNextMonthLi.setAttribute(InputDatePicker.ATTRIBUTE_DATA_CURSOR, InputDatePicker.ATTRIBUTE_DATE_FORMAT
		.format(nextMonth));

	/* Draw daypicker */
	Date dateToDrow = new Date(this.cursor.getTime());
	int selectedMonth = dateToDrow.getMonth();
	int firstMonthToDisplay = (selectedMonth + 11) % 12;
	int lastMonthToDisplay = (selectedMonth + 13) % 12;
	do {
		CalendarUtil.addDaysToDate(dateToDrow, -1);
	} while (firstMonthToDisplay != dateToDrow.getMonth() || dateToDrow.getDay() != firstDayOfWeek);

	// drow calendarTable
	TableRowElement headRow = null;
	while (dateToDrow.getMonth() != lastMonthToDisplay || dateToDrow.getDay() != lastDayOfWeek
		|| dateToDrow.getDate() == 1 && dateToDrow.getDay() == firstDayOfWeek) {
		if (headRow == null || dateToDrow.getDay() == firstDayOfWeek) {
			headRow = Document.get().createTRElement();
			this.calendatBody.appendChild(headRow);
		}
		TableCellElement td = Document.get().createTDElement();
		headRow.appendChild(td);
		DivElement div = Document.get().createDivElement();
		td.appendChild(div);
		div.setInnerText(String.valueOf(dateToDrow.getDate()));
		div.setAttribute(InputDatePicker.ATTRIBUTE_DATA_DATE, InputDatePicker.ATTRIBUTE_DATE_FORMAT.format(dateToDrow));
		if (dateToDrow.getMonth() != selectedMonth) {
			StyleUtils.addStyle(td, InputDatePicker.STYLE_MUTED);
		}
		if (dateToDrow.equals(this.cursor)) {
			StyleUtils.addStyle(td, InputDatePicker.STYLE_SELECTED);
		}
		if (this.today.equals(dateToDrow)) {
			StyleUtils.addStyle(td, InputDatePicker.STYLE_TODAY);
		}
		Event.sinkEvents(div, Event.ONCLICK);

		CalendarUtil.addDaysToDate(dateToDrow, 1);
	}
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:62,代码来源:InputDatePicker.java

示例6: handleKeyPress

import com.google.gwt.user.datepicker.client.CalendarUtil; //导入方法依赖的package包/类
private boolean handleKeyPress(int keyCode) {
	if (KeyEventUtils.isModifierKeyDown(Event.getCurrentEvent())) {
		return false;
	}
	boolean handleKey = false;
	switch (keyCode) {
		case KeyCodes.KEY_LEFT:
			CalendarUtil.addDaysToDate(this.cursor, -1);
			handleKey = true;
			break;
		case KeyCodes.KEY_RIGHT:
			CalendarUtil.addDaysToDate(this.cursor, 1);
			handleKey = true;
			break;
		case KeyCodes.KEY_UP:
			CalendarUtil.addDaysToDate(this.cursor, -7);
			handleKey = true;
			break;
		case KeyCodes.KEY_DOWN:
			CalendarUtil.addDaysToDate(this.cursor, 7);
			handleKey = true;
			break;
		case KeyCodes.KEY_PAGEUP:
			CalendarUtil.addMonthsToDate(this.cursor, -1);
			handleKey = true;
			break;
		case KeyCodes.KEY_PAGEDOWN:
			CalendarUtil.addMonthsToDate(this.cursor, 1);
			handleKey = true;
			break;
		case KeyCodes.KEY_ENTER:
			this.setValue(this.cursor, true);
			handleKey = true;
			break;
		case KeyCodes.KEY_ESCAPE:
			this.setValue(this.value);
			this.setFocus(false);
			handleKey = true;
			break;
		default:
			break;
	}
	if (handleKey) {
		this.redraw();
	}

	return handleKey;
}
 
开发者ID:Putnami,项目名称:putnami-web-toolkit,代码行数:49,代码来源:InputDatePicker.java

示例7: hasPrevMonth

import com.google.gwt.user.datepicker.client.CalendarUtil; //导入方法依赖的package包/类
private boolean hasPrevMonth(){
    Date prevMonth = CalendarUtil.copyDate(getModel().getCurrentMonth());
    CalendarUtil.addMonthsToDate(prevMonth, -1);

    return !isBeforeMinMonth(prevMonth);
}
 
开发者ID:eqlbin,项目名称:gwt-dropdown-month-datepicker,代码行数:7,代码来源:DropdownMonthSelector.java

示例8: hasNextMonth

import com.google.gwt.user.datepicker.client.CalendarUtil; //导入方法依赖的package包/类
private boolean hasNextMonth(){
    Date nextMonth = CalendarUtil.copyDate(getModel().getCurrentMonth());
    CalendarUtil.addMonthsToDate(nextMonth, 1);
    return !isAfterMaxMonth(nextMonth);
}
 
开发者ID:eqlbin,项目名称:gwt-dropdown-month-datepicker,代码行数:6,代码来源:DropdownMonthSelector.java


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