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


Java DateMidnight.equals方法代码示例

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


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

示例1: validatePeriod

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
void validatePeriod(AccountForm form, Errors errors) {

        DateMidnight holidaysAccountValidFrom = form.getHolidaysAccountValidFrom();
        DateMidnight holidaysAccountValidTo = form.getHolidaysAccountValidTo();

        validateDateNotNull(holidaysAccountValidFrom, "holidaysAccountValidFrom", errors);
        validateDateNotNull(holidaysAccountValidTo, "holidaysAccountValidTo", errors);

        if (holidaysAccountValidFrom != null && holidaysAccountValidTo != null) {
            boolean periodIsNotWithinOneYear = holidaysAccountValidFrom.getYear() != form.getHolidaysAccountYear()
                || holidaysAccountValidTo.getYear() != form.getHolidaysAccountYear();
            boolean periodIsOnlyOneDay = holidaysAccountValidFrom.equals(holidaysAccountValidTo);
            boolean beginOfPeriodIsAfterEndOfPeriod = holidaysAccountValidFrom.isAfter(holidaysAccountValidTo);

            if (periodIsNotWithinOneYear || periodIsOnlyOneDay || beginOfPeriodIsAfterEndOfPeriod) {
                errors.reject(ERROR_PERIOD);
            }
        }
    }
 
开发者ID:synyx,项目名称:urlaubsverwaltung,代码行数:20,代码来源:AccountValidator.java

示例2: getWeekDays

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
/**
 * Note: the start date must be before or equal the end date; this is validated prior to that method
 *
 * <p>This method calculates how many weekdays are between declared start date and end date (official holidays are
 * ignored here)</p>
 *
 * @param  startDate
 * @param  endDate
 *
 * @return  number of weekdays
 */
public double getWeekDays(DateMidnight startDate, DateMidnight endDate) {

    double workDays = 0.0;

    if (!startDate.equals(endDate)) {
        DateMidnight day = startDate;

        while (!day.isAfter(endDate)) {
            if (DateUtil.isWorkDay(day)) {
                workDays++;
            }

            day = day.plusDays(1);
        }
    } else {
        if (DateUtil.isWorkDay(startDate)) {
            workDays++;
        }
    }

    return workDays;
}
 
开发者ID:synyx,项目名称:urlaubsverwaltung,代码行数:34,代码来源:WorkDaysService.java

示例3: fillStats

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
private void fillStats(List<Status> list, Map<DateMidnight, Integer> map, DateMidnight start, DateMidnight end) {
    LinkedList<Status> linkedList = new LinkedList<Status>(list);
    Iterator<Status> iterator = linkedList.descendingIterator();
    if (!iterator.hasNext()) {
        return;
    }

    Multiset<DateMidnight> data = LinkedHashMultiset.create();

    Status currentStatus = iterator.next();
    DateMidnight current = new DateMidnight(currentStatus.getCreatedAt());
    while (iterator.hasNext() || currentStatus != null) {
        DateMidnight msgTime = new DateMidnight(currentStatus.getCreatedAt());
        if (current.equals(msgTime)) {
            data.add(current);
            if (iterator.hasNext()) {
                currentStatus = iterator.next();
            } else {
                currentStatus = null;
            }
        } else {
            current = current.plusDays(1);
        }
    }

    for (DateMidnight dm = start; !dm.isAfter(end); dm = dm.plusDays(1)) {
        map.put(dm, data.count(dm));
    }
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:30,代码来源:TwitterService.java

示例4: getPresentationInterval

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
public String getPresentationInterval() {
    final DateTime start = interval.getStart();
    final DateTime end = interval.getEnd();
    final DateMidnight dateMidnight = start.toDateMidnight();
    if (dateMidnight.equals(end.toDateMidnight())) {
        return String.format("%s : %s as %s", dateMidnight.toString(DATE_FORMAT), getTime(start), getTime(end));
    }
    return interval.toString();
}
 
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:10,代码来源:SpaceOccupationEventBean.java

示例5: getDateDay

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
public DateMidnight getDateDay() {
    final DateTime start = interval.getStart();
    final DateTime end = interval.getEnd();
    final DateMidnight dateMidnight = start.toDateMidnight();
    if (dateMidnight.equals(end.toDateMidnight())) {
        return dateMidnight;
    }
    return null;
}
 
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:10,代码来源:SpaceOccupationEventBean.java

示例6: getStats

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
@Override
@SqlReadonlyTransactional
public WelshareStats getStats(User user) {
    WelshareStats stats = new WelshareStats();
    List<Message> messages = getDao().getUserMessages(user, 200, 0);

    if (messages.isEmpty()) {
        return stats;
    }

    LinkedList<Message> linkedList = new LinkedList<Message>(messages);
    Iterator<Message> iterator = linkedList.descendingIterator();

    Multiset<DateMidnight> messagesData = LinkedHashMultiset.create();
    Multiset<DateMidnight> likesData = LinkedHashMultiset.create();
    Multiset<DateMidnight> repliesData = LinkedHashMultiset.create();

    Message currentMessage = iterator.next();
    DateMidnight current = new DateMidnight(currentMessage.getDateTime());
    DateMidnight start = current;
    while (iterator.hasNext() || currentMessage != null) {
        // skip imported messages
        DateMidnight msgTime = new DateMidnight(currentMessage.getDateTime());
        if (current.equals(msgTime)) {
            if (!currentMessage.isImported()) {
                messagesData.add(current);
                likesData.add(current, currentMessage.getScore());
                repliesData.add(current, currentMessage.getReplies());
            }
            if (iterator.hasNext()) {
                currentMessage = iterator.next();
            } else {
                currentMessage = null;
            }
        } else {
            current = current.plusDays(1);
        }
    }
    DateMidnight end = current;
    if (Days.daysBetween(start, end).getDays() > 30) {
        start = end.minusDays(30);
    }

    for (DateMidnight dm = start; !dm.isAfter(end); dm = dm.plusDays(1)) {
        stats.getMessages().put(dm, messagesData.count(dm));
        stats.getReplies().put(dm, repliesData.count(dm));
        stats.getLikes().put(dm, likesData.count(dm));
    }


    int days = Days.daysBetween(start, end).getDays();
    if (days == 0) {
        return stats; // no further calculation
    }

    int[] messagesMaxAndSum = CollectionUtils.getMaxAndSum(stats.getMessages());
    stats.setMaxMessages(messagesMaxAndSum[0]);
    stats.setAverageMessages(messagesMaxAndSum[1] / days);

    int[] likesMaxAndSum = CollectionUtils.getMaxAndSum(stats.getLikes());
    stats.setMaxLikes(likesMaxAndSum[0]);
    stats.setAverageLikes(likesMaxAndSum[1] / days);

    int[] repliesMaxAndSum = CollectionUtils.getMaxAndSum(stats.getReplies());
    stats.setMaxReplies(repliesMaxAndSum[0]);
    stats.setAverageReplies(repliesMaxAndSum[1] / days);

    stats.setMaxCount(NumberUtils.max(
            stats.getMaxMessages(),
            stats.getMaxReplies(),
            stats.getMaxLikes()));

    return stats;
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:75,代码来源:MessageServiceImpl.java

示例7: updateCreditCard

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
/**
 * Updates a users stored credit card to the given details. If the given credit card is
 * null then the user's existing credit card will be deleted.
 *
 * @param userId user to update
 * @param creditCard credit card details
 * @throws SessionInternalError
 */
public void updateCreditCard(Integer userId, com.sapienter.jbilling.server.entity.CreditCardDTO creditCard)
        throws SessionInternalError {

    if (creditCard == null) {
        deleteCreditCard(userId);
        return;
    }

    // validate
    if (StringUtils.isEmpty(creditCard.getName())) throw new SessionInternalError("Credit card name cannot be empty.");
    if (creditCard.getExpiry() == null) throw new SessionInternalError("Credit card expiry date cannot be null.");

    // validate against existing credit card (if updating)
    if (creditCard.getId() != null && !creditCard.getId().equals(0)) {
        CreditCardDTO savedCreditCard = new CreditCardDAS().find(creditCard.getId());

        // if no number was given, use the exiting credit card number that we have in the database
        if (creditCard.getNumber() == null || creditCard.getNumber().contains("*")) {
            creditCard.setNumber(savedCreditCard.getNumber());
        }

        // verify that something has actually been changed before doing any real work
        DateMidnight oldExpiry = new DateMidnight(savedCreditCard.getExpiry()).withDayOfMonth(1);
        DateMidnight newExpiry = new DateMidnight(creditCard.getExpiry()).withDayOfMonth(1);

        if (creditCard.getName().equals(savedCreditCard.getName())
                && newExpiry.equals(oldExpiry)
                && creditCard.getNumber().equals(savedCreditCard.getNumber())) {

            LOG.debug("No credit card details have been changed, no need to update.");
            creditCard.setHasChanged(false);
            return;
        }

        LOG.debug("Credit card details have changed, doing update.");
        creditCard.setHasChanged(true);
    }

    // do the update
    IUserSessionBean userSession = Context.getBean(Context.Name.USER_SESSION);
    userSession.updateCreditCard(getCallerId(), userId, new CreditCardDTO(creditCard));
}
 
开发者ID:maxdelo77,项目名称:replyit-master-3.2-final,代码行数:51,代码来源:WebServicesSessionSpringBean.java

示例8: intervalsHaveGap

import org.joda.time.DateMidnight; //导入方法依赖的package包/类
/**
 * Check if the two given intervals have a gap or if they abut.
 *
 * <p>Some examples:</p>
 *
 * <p>(1) period 16.-18. and period 19.-20. --> they abut</p>
 *
 * <p>(2) period 16.-18. and period 20.-22. --> they have a gap</p>
 *
 * @param  firstInterval
 * @param  secondInterval
 *
 * @return  {@code true} if they have a gap between or {@code false} if they have no gap
 */
private boolean intervalsHaveGap(Interval firstInterval, Interval secondInterval) {

    // test if end of interval is equals resp. one day plus of start of other interval
    DateMidnight endOfFirstInterval = firstInterval.getEnd().toDateMidnight();
    DateMidnight startOfSecondInterval = secondInterval.getStart().toDateMidnight();

    return !(endOfFirstInterval.equals(startOfSecondInterval)
            || endOfFirstInterval.plusDays(1).equals(startOfSecondInterval));
}
 
开发者ID:synyx,项目名称:urlaubsverwaltung,代码行数:24,代码来源:OverlapService.java


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