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


Java DateTime.compareTo方法代码示例

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


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

示例1: setSelected

import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
 * Select the day specified if multiple selection mode is not enabled,
 * otherwise adjust the ends of the selection:
 * first end will be set if the day specified is before the first end;
 * last end will be set if the day specified is after the last end;
 *
 * @param dateSelected a DateTime object that represents the day that
 *                     should be selected
 */
@Override
public void setSelected(DateTime dateSelected) {
    if (viewInteractor != null && viewInteractor.hasImplementedSelection()) {
        int itemSelected = viewInteractor.setSelected(multipleSelection, dateSelected);
        switch (itemSelected) {
            case 0:
                notifyFirstSelectionUpdated(dateSelected);
                break;
            case 1:
                notifyLastSelectionUpdated(dateSelected);
                break;
            default:
                return;
        }
    } else {
        if (!multipleSelection) {
            notifyFirstSelectionUpdated(dateSelected);
        } else {
            if (firstSelectedDay != null) {
                int startSelectedCompared = dateSelected.compareTo(firstSelectedDay);
                if (startSelectedCompared < 0) {
                    notifyFirstSelectionUpdated(dateSelected);
                } else if (lastSelectedDay != null) {
                    int endSelectedCompared = dateSelected.compareTo(lastSelectedDay);
                    if ((startSelectedCompared >= 0 && endSelectedCompared < 0) || endSelectedCompared > 0) {
                        notifyLastSelectionUpdated(dateSelected);
                    }
                } else {
                    notifyLastSelectionUpdated(dateSelected);
                }
            } else {
                notifyFirstSelectionUpdated(dateSelected);
            }
        }
    }
    notifyDataSetChanged();
}
 
开发者ID:MOLO17,项目名称:CustomizableCalendar,代码行数:47,代码来源:MonthAdapter.java

示例2: createOrderedDailyMenu

import org.joda.time.DateTime; //导入方法依赖的package包/类
private DailyMenu createOrderedDailyMenu(LocalDate currentDay, Long reqUserid) throws ApiException {

        com.jrtechnologies.yum.data.entity.User user = getUserOfDailyOrder(reqUserid);
        
        com.jrtechnologies.yum.data.entity.DailyMenu dailyMenuEntity = dailyMenuRepo.findByDate(currentDay);
        DailyMenu dailyMenu = new DailyMenu();
        if (dailyMenuEntity == null) {
            return dailyMenu;
        }
        com.jrtechnologies.yum.data.entity.DailyOrder dailyOrderEntity = dailyOrderRepo.findByUserIdAndDailyMenuId(user.getId(), dailyMenuEntity.getId());

        DateTime  deadline = getDeadline(currentDay);
        dailyMenu.setLastOrderDateTime(deadline);

        if (dailyOrderEntity != null) {
            dailyMenu.setId(dailyMenuEntity.getId());
            dailyMenu.setDate(dailyMenuEntity.getDate());
            dailyMenu.setOrderId(dailyOrderEntity.getDailyOrderId());
            LastEdit lastEdit = new LastEdit();
            lastEdit.setTimeStamp(dailyMenuEntity.getLastEdit());
            lastEdit.setVersion(dailyMenuEntity.getVersion());
            dailyMenu.setLastEdit(lastEdit);  
            
            //Boolean finalisedDailyOrder = deadline.compareTo(LocalDateTime.now())<0;
            Boolean finalisedDailyOrder = deadline.compareTo(DateTime.now(DateTimeZone.UTC))<0;
            
            dailyOrderEntity.setFinalised(finalisedDailyOrder);
            dailyMenu.setIsFinal(finalisedDailyOrder);
            
            for (com.jrtechnologies.yum.data.entity.Food foodEntity : dailyMenuEntity.getFoods()) {
                FoodWithQuantity foodWithQuantity = new FoodWithQuantity();
                foodWithQuantity.setFood(createFood(foodEntity)); //Create and add food in foodWithQuantity.
                OrderItemId orderItemId = new OrderItemId();
                orderItemId.setDailyOrderId(dailyOrderEntity.getDailyOrderId());
                orderItemId.setFoodId(foodEntity.getId());
                com.jrtechnologies.yum.data.entity.OrderItem orderItemEntity = orderItemRepo.findById(orderItemId);
                if (orderItemEntity != null) { //Check the food how many times is ordered.
                    foodWithQuantity.setQuantity(orderItemEntity.getQuantity());
                } else {
                    foodWithQuantity.setQuantity(0);
                }
                dailyMenu.addFoodsItem(foodWithQuantity); //Add the food in daily menu.
            }
         
        } else if (deadline.compareTo(DateTime.now(DateTimeZone.UTC))>0) {
            dailyMenuEntity.setFinalised(false);
            dailyMenu.setDate(dailyMenuEntity.getDate());
            dailyMenu.setIsFinal(false);
        }

        return dailyMenu;
    }
 
开发者ID:jrtechnologies,项目名称:yum,代码行数:53,代码来源:MenusService.java

示例3: getEventDetailsSorter

import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
 * Returns a Comparator for (re-)sorting events, typically used after
 *  expanding out recurring instances.
 */
protected static Comparator<Map<String, Object>> getEventDetailsSorter()
{
   return new Comparator<Map<String, Object>>() 
   {
      public int compare(Map<String, Object> resultA,
            Map<String, Object> resultB) 
      {
     	 DateTimeFormatter fmtNoTz  = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSS");
     	 DateTimeFormatter fmtTz  =   DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZZ");
     	 
     	 String startA = (String)resultA.get(RESULT_START);
     	 String startB = (String)resultB.get(RESULT_START);
     
     	 startA = startA.replace("Z", "+00:00");
     	 startB = startB.replace("Z", "+00:00");
     	 
     	 //check and parse iso8601 date without time zone (All day events are stripped of time zone)
     	 DateTime sa = startA.length()>23?fmtTz.parseDateTime(startA):fmtNoTz.parseDateTime(startA);
     	 DateTime sb = startB.length()>23?fmtTz.parseDateTime(startB):fmtNoTz.parseDateTime(startB);

         int cmp = sa.compareTo(sb);
         if (cmp == 0)
         {
         	String endA = (String)resultA.get(RESULT_END);
         	String endB = (String)resultB.get(RESULT_END);
         	
         	DateTime ea = endA.length()>23?fmtTz.parseDateTime(endA):fmtNoTz.parseDateTime(endA);
         	DateTime eb = endB.length()>23?fmtTz.parseDateTime(endB):fmtNoTz.parseDateTime(endB);

            cmp = ea.compareTo(eb);
            if (cmp == 0)
            {
               String nameA = (String)resultA.get(RESULT_NAME);
               String nameB = (String)resultB.get(RESULT_NAME);
               return nameA.compareTo(nameB);
            }
            return cmp;
         }
         return cmp;
      }
   };
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:47,代码来源:AbstractCalendarListingWebScript.java


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