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


Java Calendar.equals方法代码示例

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


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

示例1: dispatchOnRangeSelected

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * Dispatch a range of days to a listener, if set. First day must be before last Day.
 *
 * @param firstDay first day enclosing a range
 * @param lastDay  last day enclosing a range
 */
protected void dispatchOnRangeSelected(final CalendarDay firstDay, final CalendarDay lastDay) {
    final OnRangeSelectedListener listener = rangeListener;
    final List<CalendarDay> days = new ArrayList<>();

    final Calendar counter = Calendar.getInstance();
    counter.setTime(firstDay.getDate());  //  start from the first day and increment

    final Calendar end = Calendar.getInstance();
    end.setTime(lastDay.getDate());  //  for comparison

    while (counter.before(end) || counter.equals(end)) {
        final CalendarDay current = CalendarDay.from(counter);
        adapter.setDateSelected(current, true);
        days.add(current);
        counter.add(Calendar.DATE, 1);
    }

    if (listener != null) {
        listener.onRangeSelected(MaterialCalendarView.this, days);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:MaterialCalendarView.java

示例2: dispatchOnRangeSelected

import java.util.Calendar; //导入方法依赖的package包/类
/**
     * Dispatch a range of days to a listener, if set. First day must be before last Day.
     *
     * @param firstDay first day enclosing a range
     * @param lastDay  last day enclosing a range
     */
    protected void dispatchOnRangeSelected(final CalendarDay firstDay, final CalendarDay lastDay) {
        final OnRangeSelectedListener listener = rangeListener;
        final List<CalendarDay> days = new ArrayList<>();

        final Calendar counter = Calendar.getInstance();
        counter.setTime(firstDay.getDate());  //  start from the first day and increment

        final Calendar end = Calendar.getInstance();
        end.setTime(lastDay.getDate());  //  for comparison

        while (counter.before(end) || counter.equals(end)) {
            final CalendarDay current = CalendarDay.from(counter);
//            adapter.setDateSelected(current, true);
            days.add(current);
            counter.add(Calendar.DATE, 1);
        }

        Collections.sort(days, new CalendarDayComparator());
        adapter.setDateRangeSelected(days);

        if (listener != null) {
            listener.onRangeSelected(CalendarView2.this, days);
        }
    }
 
开发者ID:ptrstovka,项目名称:calendarview2,代码行数:31,代码来源:CalendarView2.java

示例3: isThisWeek

import java.util.Calendar; //导入方法依赖的package包/类
private static boolean isThisWeek (Calendar scheduleDay, Calendar until) {
    Calendar weekStart = Calendar.getInstance();
    stripTime(weekStart);
    weekStart.set(Calendar.DAY_OF_WEEK, weekStart.getFirstDayOfWeek());
    Calendar weekEnd = Calendar.getInstance();
    weekEnd.setTime(weekStart.getTime());
    weekEnd.add(Calendar.DATE, 7);
    
    return scheduleDay.equals(weekStart) && until.equals(weekEnd);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:SchedulingPickerImpl.java

示例4: isNextWeek

import java.util.Calendar; //导入方法依赖的package包/类
private static boolean isNextWeek (Calendar scheduleDay, Calendar until) {
    Calendar weekStart = Calendar.getInstance();
    stripTime(weekStart);
    weekStart.set(Calendar.DAY_OF_WEEK, weekStart.getFirstDayOfWeek());
    weekStart.add(Calendar.DATE, 7);
    Calendar weekEnd = Calendar.getInstance();
    weekEnd.setTime(weekStart.getTime());
    weekEnd.add(Calendar.DATE, 7);
    
    return scheduleDay.equals(weekStart) && until.equals(weekEnd);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:SchedulingPickerImpl.java

示例5: formatDateDiff

import java.util.Calendar; //导入方法依赖的package包/类
public static String formatDateDiff(Calendar fromDate, Calendar toDate) {
	boolean future = false;
	if (toDate.equals(fromDate)) {
		return I18N.tr("now");
	}
	if (toDate.after(fromDate)) {
		future = true;
	}
	StringBuilder sb = new StringBuilder();
	int[] types = { Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND };
	String[] names = {
		I18N.tr("year"), I18N.tr("years"),
		I18N.tr("month"), I18N.tr("months"),
		I18N.tr("day"), I18N.tr("days"),
		I18N.tr("hour"), I18N.tr("hours"),
		I18N.tr("minute"), I18N.tr("minutes"),
		I18N.tr("second"), I18N.tr("seconds")
	};
	int accuracy = 0;
	for (int i = 0; i < types.length; i++) {
		if (accuracy > 2) {
			break;
		}
		int diff = dateDiff(types[i], fromDate, toDate, future);
		if (diff > 0) {
			accuracy++;
			sb.append(" ").append(diff).append(" ").append(names[i * 2 + (diff > 1 ? 1 : 0)]);
		}
	}
	if (sb.length() == 0) {
		return "now";
	}
	return sb.toString().trim();
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:35,代码来源:DateUtils.java

示例6: skipCompare

import java.util.Calendar; //导入方法依赖的package包/类
@Override
protected boolean skipCompare(final String columnName, final Object expectedValue, final Object actualValue) {
    final boolean result;
    if (actualValue instanceof Timestamp && TODAY.equals(expectedValue)) {
        final Calendar actualCalendar = Calendar.getInstance();
        final Calendar expectedCalendar = (Calendar) actualCalendar.clone();
        actualCalendar.setTimeInMillis(((Timestamp) actualValue).getTime());
        clearTime(actualCalendar);
        clearTime(expectedCalendar);
        result = actualCalendar.equals(expectedCalendar);
    } else {
        result = false;
    }
    return result;
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:16,代码来源:AbstractDBUnitUtil.java

示例7: getScheduledTime

import java.util.Calendar; //导入方法依赖的package包/类
public static Date getScheduledTime() {

        Calendar startTime = Calendar.getInstance();
        Calendar now = Calendar.getInstance();
        startTime.set(Calendar.HOUR_OF_DAY, 0);
        startTime.set(Calendar.MINUTE, 0);
        startTime.set(Calendar.SECOND, 0);
        startTime.set(Calendar.MILLISECOND, 0);

        if (startTime.before(now) || startTime.equals(now)) {
            startTime.add(Calendar.DATE, 1);
        }

        return startTime.getTime();
    }
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:16,代码来源:Tools.java

示例8: days

import java.util.Calendar; //导入方法依赖的package包/类
public List<CalendarDay> days() {
    List<CalendarDay> calendarDays = new ArrayList<>();
    Calendar from = Calendar.getInstance();
    this.from.copyTo(from);
    Calendar to = Calendar.getInstance();
    this.to.copyTo(to);

    while (from.before(to) || from.equals(to)) {
        calendarDays.add(CalendarDay.from(from));
        from.add(Calendar.DAY_OF_YEAR, 1);
    }

    return calendarDays;
}
 
开发者ID:ptrstovka,项目名称:calendarview2,代码行数:15,代码来源:Range.java

示例9: Test4080631

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * 4080631: Calendar.hashCode is amazingly bad
 */
public void Test4080631() {
    Calendar cal = Calendar.getInstance();
    int h1 = cal.hashCode();
    cal.add(SECOND, +1);
    int h2 = cal.hashCode();
    Calendar cal2 = (Calendar) cal.clone();
    cal.add(MILLISECOND, +1);
    int h3 = cal.hashCode();
    logln("hash code: h1=" + h1 + ", h2=" + h2 + ", h3=" + h3);
    if (h1 == h2 || h1 == h3 || h2 == h3) {
        errln("hash code is poor: hashCode=" + h1);
    }
    h2 = cal2.hashCode();
    cal.add(MILLISECOND, -1);
    int h4 = cal.hashCode();
    logln("hash code: h2=" + h2 + ", h4=" + h4);
    if (cal.equals(cal2) && h2 != h4) {
        errln("broken hash code: h2=" + h2 + ", h4=" + h4);
    }
    int x = cal.getFirstDayOfWeek() + 3;
    if (x > SATURDAY) {
        x -= 7;
    }
    cal.setFirstDayOfWeek(x);
    int h5 = cal.hashCode();
    logln("hash code: h4=" + h4 + ", h5=" + h5);
    if (h4 == h5) {
        errln("has code is poor with first day of week param: hashCode=" + h4);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:CalendarRegression.java

示例10: isAnotherDaySelected

import java.util.Calendar; //导入方法依赖的package包/类
private boolean isAnotherDaySelected(SelectedDay selectedDay, Calendar day) {
    return selectedDay != null && !day.equals(selectedDay.getCalendar())
            && isCurrentMonthDay(day) && isActiveDay(day);
}
 
开发者ID:Applandeo,项目名称:Material-Calendar-View,代码行数:5,代码来源:DayRowClickListener.java

示例11: Test4413980

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * Test whether Calendar can be serialized/deserialized correctly
 * even if invalid/customized TimeZone is used.
 */
public void Test4413980() {
    TimeZone savedTimeZone = TimeZone.getDefault();
    try {
        boolean pass = true;
        String[] IDs = new String[]{"Undefined", "PST", "US/Pacific",
            "GMT+3:00", "GMT-01:30"};
        for (int i = 0; i < IDs.length; i++) {
            TimeZone tz = TimeZone.getTimeZone(IDs[i]);
            TimeZone.setDefault(tz);

            Calendar c = Calendar.getInstance();

            // serialize
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            ObjectOutputStream s = new ObjectOutputStream(out);
            s.writeObject(c);
            s.flush();

            // deserialize
            ObjectInputStream t = new ObjectInputStream(new ByteArrayInputStream(out.toByteArray()));

            if (!c.equals(t.readObject())) {
                pass = false;
                logln("Calendar instance which uses TimeZone <"
                        + IDs[i] + "> is incorrectly serialized/deserialized.");
            } else {
                logln("Calendar instance which uses TimeZone <"
                        + IDs[i] + "> is correctly serialized/deserialized.");
            }
        }
        if (!pass) {
            errln("Fail: Calendar serialization/equality bug");
        }
    } catch (IOException | ClassNotFoundException e) {
        errln("Fail: " + e);
        e.printStackTrace();
    } finally {
        TimeZone.setDefault(savedTimeZone);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:45,代码来源:CalendarRegression.java

示例12: setCurrentMonthDayColors

import java.util.Calendar; //导入方法依赖的package包/类
/**
 * This method is used to set a color of texts, font types and backgrounds of TextView objects
 * in a current visible month. Visible day labels from previous and forward months are set using
 * setDayColors() method. It also checks if a day number is a day number of today and set it
 * a different color and bold face type.
 *
 * @param day                A calendar instance representing day date
 * @param today              A calendar instance representing today date
 * @param dayLabel           TextView containing a day number
 * @param calendarProperties A resource of a color used to mark today day
 */
public static void setCurrentMonthDayColors(Calendar day, Calendar today, TextView dayLabel,
                                            CalendarProperties calendarProperties) {
    if (today.equals(day)) {
        setDayColors(dayLabel, calendarProperties.getTodayLabelColor(), Typeface.BOLD,
                R.drawable.background_transparent);
    } else {
        setDayColors(dayLabel, calendarProperties.getDaysLabelsColor(), Typeface.NORMAL,
                R.drawable.background_transparent);
    }
}
 
开发者ID:Applandeo,项目名称:Material-Calendar-View,代码行数:22,代码来源:DayColorsUtils.java


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