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


Java CalendarUtil类代码示例

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


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

示例1: createDateFrom

import com.google.gwt.user.datepicker.client.CalendarUtil; //导入依赖的package包/类
private DateItem createDateFrom(String fName, DateRangeValidator dateRangeValidator) {
    DateItem dateStart = new DateItem(fName, i18n.NewIssueEditor_dateFrom_Title());
    dateStart.setTooltip(i18n.NewIssueEditor_dateFrom_Hint());
    dateStart.setUseTextField(true);
    dateStart.setRequired(true);
    dateStart.setStartDate(new Date(1900 - 1900, 1, 1));
    dateStart.addChangedHandler((event) -> {
        Date min = dateStart.getValueAsDate();
        Date max = null;
        if (min != null) {
            max = CalendarUtil.copyDate(min);
            max.setMonth(11);
            max.setDate(31);
        }
        dateRangeValidator.setMin(min);
        dateRangeValidator.setMax(max);
    });
    return dateStart;
}
 
开发者ID:proarc,项目名称:proarc,代码行数:20,代码来源:NewIssueEditor.java

示例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);
        GWT.log(""+t[3]);
	}catch(Exception e){
		e.printStackTrace();
	}
	return t;
}
 
开发者ID:arscyper,项目名称:adan,代码行数:19,代码来源:CommonUtil.java

示例3: 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;
}
 
开发者ID:arscyper,项目名称:adan,代码行数:18,代码来源:PrayTime.java

示例4: 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

示例5: setDateRange

import com.google.gwt.user.datepicker.client.CalendarUtil; //导入依赖的package包/类
public void setDateRange(Date minDate, Date maxDate) {

        if(maxDate.before(minDate))
            throw new IllegalArgumentException(
                    "The value of the maxDate must not be before value of the minDate!");
        
        this.minDate = CalendarUtil.copyDate(minDate);
        CalendarUtil.resetTime(this.minDate);
        this.maxDate = CalendarUtil.copyDate(maxDate);
        CalendarUtil.resetTime(this.maxDate);
        
        int currentYear = getCurrentYear();
        int minYear = getMinYear();
        int maxYear = getMaxYear();
        
        if(currentYear < minYear || currentYear > maxYear) {
            currentYear = minYear + (maxYear - minYear)/2;
            setCurrentYear(currentYear);
        }
        
        refreshAll();
    }
 
开发者ID:eqlbin,项目名称:gwt-dropdown-month-datepicker,代码行数:23,代码来源:DropdownMonthSelector.java

示例6: 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);
    }
}
 
开发者ID:vaadin,项目名称:touchkit,代码行数:19,代码来源:CalendarOverlay.java

示例7: weekNumber

import com.google.gwt.user.datepicker.client.CalendarUtil; //导入依赖的package包/类
@SuppressWarnings("deprecation")
static int weekNumber(int year, int month) {
	Date d = new Date(year - 1900, month - 1, 1);
	while (d.getDay() != CalendarUtil.getStartingDayOfWeek()) d.setDate(d.getDate() - 1);
	int y = d.getYear();
	int week = 0;
	while (d.getYear() == y) { d.setDate(d.getDate() - 7); week += 1; }
	return week;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:10,代码来源:PeriodPreferencesWidget.java

示例8: buildOverlay

import com.google.gwt.user.datepicker.client.CalendarUtil; //导入依赖的package包/类
@Override
public JavaScriptObject buildOverlay(Message prev, Message current, Message next) {
    Date nextDate = next != null ? new Date(next.getDate()) : null;
    Date currentDate = new Date(current.getDate());

    boolean showDate;
    String dateDiv = null;
    if (next != null) {
        showDate = !CalendarUtil.isSameDate(nextDate, currentDate);
    } else {
        showDate = true;
    }
    if (showDate) {
        dateDiv = JsMessenger.getInstance().getFormatter().formatMonth(currentDate);
    }

    boolean useCompact = false;
    if (next != null && !showDate) {
        if (next.getSenderId() == current.getSenderId()) {
            if (next.getDate() - current.getDate() < 10 * 60 * 1000) {
                useCompact = true;
            }
        }
    }

    return JsMessageOverlay.create(useCompact, dateDiv);
}
 
开发者ID:wex5,项目名称:dangchat-sdk,代码行数:28,代码来源:JsMessage.java

示例9: 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;
}
 
开发者ID:arscyper,项目名称:adan,代码行数:16,代码来源:PrayTime.java

示例10: isEmpty

import com.google.gwt.user.datepicker.client.CalendarUtil; //导入依赖的package包/类
/**
 * to decide what textbox component contains date information
 *
 * @param precision
 * @return
 */
public boolean isEmpty(Precision precision) {
    switch (precision) {
        case YOO_OO:
            return "1".equals(precision.getFormatter().format(date));
        case YMO_OO:
            return "1.1".equals(precision.getFormatter().format(date));

        // FIXME
        case YMD_OO:
            return "0001.01.01".equals(precision.getFormatter().format(date))
                || "0000.12.30".equals(precision.getFormatter().format(date)); // don't
                                                                               // know
                                                                               // what
                                                                               // happens
                                                                               // in
                                                                               // compiled
                                                                               // code
        case YMD_HM:
            return CalendarUtil.isSameDate(date, new Date(NULLDATE));

        case OMO_OO:
        case OOO_HM:
        case OOO_HO:
        case OOO_OM:
        case OOO_HMS:
            return false;
    }

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

示例11: 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

示例12: onClick

import com.google.gwt.user.datepicker.client.CalendarUtil; //导入依赖的package包/类
@Override
public void onClick(ClickEvent event) {
    if (enabled) {
        if (!CalendarUtil
            .isSameDate(inedate.getDateClone(), new Date(IneDateGWT.NULLDATE))) {
            datepicker.setCurrentMonth(inedate.getDateClone());
            datepicker.setValue(inedate.getDateClone());
        } else {
            datepicker.setCurrentMonth(dateProv.getDate(System.currentTimeMillis()));
            datepicker.setValue(dateProv.getDate(System.currentTimeMillis()));
        }
        popup.showRelativeTo(img_calendar);
    }
}
 
开发者ID:inepex,项目名称:ineform,代码行数:15,代码来源:YMD_OOField.java

示例13: 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

示例14: updateUI

import com.google.gwt.user.datepicker.client.CalendarUtil; //导入依赖的package包/类
/**
     * Sets the values ​​in the components {@link #yearsDropdown}
     * and {@link #monthsDropdown}, which correspond to the current month of the 
     * {@link com.google.gwt.user.datepicker.client.CalendarModel CalendarModel}
     */
    private void updateUI() { 

        Date currentMonth = CalendarUtil.copyDate(getModel().getCurrentMonth());
        
        if(isBeforeMinMonth(currentMonth)) {
            getModel().setCurrentMonth(minDate);
            refreshAll();
            return;
//            throw new MonthOutOfRangeException(
//                    "The month " + MONTH_FORMAT.format(currentMonth) 
//                     + " is before the minimum month " + MONTH_FORMAT.format(minDate));
        } else if(isAfterMaxMonth(currentMonth)) {
            getModel().setCurrentMonth(maxDate);
            refreshAll();
            return;
//            throw new MonthOutOfRangeException(
//                    "The month " + MONTH_FORMAT.format(currentMonth) 
//                     + " is after the maximum month " + MONTH_FORMAT.format(maxDate));
        }
        
        rebuildYearsDropdown();
        rebuildMonthsDropdown();
        
        currentMonthLabel.setText(MONTH_FORMAT_LABEL.format(currentMonth));

        currentMonthPanel.clear();
        if(dropdownVisible) {
            currentMonthPanel.add(monthsDropdown);
            currentMonthPanel.add(yearsDropdown);
        } else {
            currentMonthPanel.add(currentMonthLabel);
        }
        
        prevYearButton.setVisible(yearsButtonsVisible);
        nextYearButton.setVisible(yearsButtonsVisible);
        
        updateButtonsState();
    }
 
开发者ID:eqlbin,项目名称:gwt-dropdown-month-datepicker,代码行数:44,代码来源:DropdownMonthSelector.java

示例15: isBeforeMinMonth

import com.google.gwt.user.datepicker.client.CalendarUtil; //导入依赖的package包/类
public boolean isBeforeMinMonth(Date month) {
    if(!isRangeSet()) return false;
    
    Date minMonth = CalendarUtil.copyDate(minDate);
    CalendarUtil.setToFirstDayOfMonth(minMonth);

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


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