本文整理汇总了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();
}
}
}