當前位置: 首頁>>代碼示例>>Java>>正文


Java LocalTime.isEqual方法代碼示例

本文整理匯總了Java中org.joda.time.LocalTime.isEqual方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalTime.isEqual方法的具體用法?Java LocalTime.isEqual怎麽用?Java LocalTime.isEqual使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.joda.time.LocalTime的用法示例。


在下文中一共展示了LocalTime.isEqual方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validateBreakInsideTimeTrack

import org.joda.time.LocalTime; //導入方法依賴的package包/類
private void validateBreakInsideTimeTrack(TimeTrack timeTrack, Break toInsert) throws UserException {
   LocalTime timeTrackStart = timeTrack.getFrom().toLocalTime();
   LocalTime timeTrackEnd = timeTrack.getTo().toLocalTime();

   LocalTime breakStart = toInsert.getFrom().toLocalTime();
   LocalTime breakEnd = toInsert.getTo().toLocalTime();

   // we have nightWork, if start of work e.g. 7pm is "after" 6am
   //   we can trust that original start and end times in module TimeTrack.class are validated to be start before end
   //   but above DateTime is parsed to LocalTime, which means we have no date any more
   boolean nightWork = timeTrackStart.isAfter(timeTrackEnd);
   if(nightWork) {
      // e.g. break is between 8pm and midnight and also after begin of work
      if(breakStart.isAfter(timeTrackStart) && breakEnd.isAfter(timeTrackStart)) {
         return;
      }
      // e.g. break is between midnight and 7am
      if(breakStart.isBefore(timeTrackEnd) && breakEnd.isBefore(timeTrackEnd)) {
         return;
      }
      // e.g. break is over midnight
      if(breakStart.isAfter(timeTrackStart) && breakEnd.isBefore(timeTrackEnd)) {
         return;
      }
      // e.g. break and timeTrack is starting or ending at same moment
      if(breakStart.isEqual(timeTrackStart) || breakEnd.isEqual(timeTrackEnd)) {
         return;
      }
      throwBreakNotInsideTimeTrackException();

   } else {
      if(breakStart.isBefore(timeTrackStart) || breakEnd.isAfter(timeTrackEnd)) {
         throwBreakNotInsideTimeTrackException();
      }
   }
}
 
開發者ID:peerdavid,項目名稱:ComeAndGo,代碼行數:37,代碼來源:TimeTrackingValidationImpl.java


注:本文中的org.joda.time.LocalTime.isEqual方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。