本文整理汇总了Java中com.google.gwt.user.datepicker.client.CalendarUtil.addDaysToDate方法的典型用法代码示例。如果您正苦于以下问题:Java CalendarUtil.addDaysToDate方法的具体用法?Java CalendarUtil.addDaysToDate怎么用?Java CalendarUtil.addDaysToDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.user.datepicker.client.CalendarUtil
的用法示例。
在下文中一共展示了CalendarUtil.addDaysToDate方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTimeInfo
import com.google.gwt.user.datepicker.client.CalendarUtil; //导入方法依赖的package包/类
public static int[] getTimeInfo(int i){
int[] t = new int[4];
try{
Date now = new Date();
CalendarUtil.addDaysToDate(now, i);
DateTimeFormat fmt = DateTimeFormat.getFormat("yyyy/MM/dd/Z");
String s[] = fmt.format(now).split("/");
t[0] = Integer.parseInt(s[0]);
t[1] = Integer.parseInt(s[1]);
t[2] = Integer.parseInt(s[2]);
t[3] = getZone(s);
GWT.log(""+t[3]);
}catch(Exception e){
e.printStackTrace();
}
return t;
}
示例2: getTimeInfo
import com.google.gwt.user.datepicker.client.CalendarUtil; //导入方法依赖的package包/类
public static int[] getTimeInfo(int i){
int[] t = new int[4];
try{
Date now = new Date();
CalendarUtil.addDaysToDate(now, i);
DateTimeFormat fmt = DateTimeFormat.getFormat("yyyy/MM/dd/Z");
String s[] = fmt.format(now).split("/");
t[0] = Integer.parseInt(s[0]);
t[1] = Integer.parseInt(s[1]);
t[2] = Integer.parseInt(s[2]);
t[3] = getZone(s);
}catch(Exception e){
e.printStackTrace();
}
return t;
}
示例3: 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);
}
示例4: disableDaysNotInCurrentMonth
import com.google.gwt.user.datepicker.client.CalendarUtil; //导入方法依赖的package包/类
private void disableDaysNotInCurrentMonth(Date startDay, Date endDay) {
List<Date> disableDates = new LinkedList<Date>();
Date firstDayOfMonth = firstDayOfMonth(calendarWidget
.getCurrentMonth());
Date lastDayOfMonth = lastDayOfMonth(calendarWidget
.getCurrentMonth());
Date dayAfterEnd = (Date) endDay.clone();
CalendarUtil.addDaysToDate(dayAfterEnd, 1);
for (Date day = startDay; day.before(dayAfterEnd); CalendarUtil
.addDaysToDate(day, 1)) {
if (day.before(firstDayOfMonth) || day.after(lastDayOfMonth)) {
disableDates.add((Date) day.clone());
}
}
if (!disableDates.isEmpty()) {
calendarWidget.setTransientEnabledOnDates(false, disableDates);
}
}
示例5: getMonthInfo
import com.google.gwt.user.datepicker.client.CalendarUtil; //导入方法依赖的package包/类
public String[] getMonthInfo(int i){
String[] s = new String[2];
try{
Date now = new Date();
CalendarUtil.addDaysToDate(now, i);
DateTimeFormat fmt = DateTimeFormat.getFormat("dd/MMM");
String s1[] = fmt.format(now).split("/");
return s1;
}catch(Exception e){
e.printStackTrace();
}
return s;
}
示例6: 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());
}
示例7: 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);
}
示例8: getDate
import com.google.gwt.user.datepicker.client.CalendarUtil; //导入方法依赖的package包/类
static Date getDate(Date firstDate, int offset) {
Date d = new Date(firstDate.getTime());
if (offset != 0) CalendarUtil.addDaysToDate(d, offset);
return d;
}
示例9: getPreviousDate
import com.google.gwt.user.datepicker.client.CalendarUtil; //导入方法依赖的package包/类
protected Date getPreviousDate(Date date) {
Date prev = new Date(date.getTime());
CalendarUtil.addDaysToDate(prev, -1);
return prev;
}
示例10: getMetaDate
import com.google.gwt.user.datepicker.client.CalendarUtil; //导入方法依赖的package包/类
public static String getMetaDate(int i){
Date now = new Date();
CalendarUtil.addDaysToDate(now, i);
DateTimeFormat fmt = DateTimeFormat.getFormat("yyyy-MM-dd");
return fmt.format(now);
}
示例11: 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);
}
}
示例12: 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;
}