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


Java LocalTime.isAfter方法代碼示例

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


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

示例1: filterByDateTimeAndDirection

import org.joda.time.LocalTime; //導入方法依賴的package包/類
public static ArrayList<PossibleTrip> filterByDateTimeAndDirection(ArrayList<PossibleTrip> possibleTrips, LocalDateTime dateTime, Boolean arriving) {
  ArrayList<PossibleTrip> possibleTripsFiltered = new ArrayList<>();

  for (PossibleTrip possibleTrip : possibleTrips) {
    LocalTime departureTime = possibleTrip.getDepartureTime();
    LocalTime arrivalTime = possibleTrip.getArrivalTime();

    if (!arriving) {
      if (departureTime.isAfter(dateTime.toLocalTime())) {
        possibleTripsFiltered.add(possibleTrip);
      }
    } else {
      if (arrivalTime.isBefore(dateTime.toLocalTime()) && arrivalTime.isAfter(dateTime.minusHours(3).toLocalTime())) {
        possibleTripsFiltered.add(possibleTrip);
      }
    }
  }

  return possibleTripsFiltered;
}
 
開發者ID:eleith,項目名稱:calchoochoo,代碼行數:21,代碼來源:PossibleTripUtils.java

示例2: setLocation

import org.joda.time.LocalTime; //導入方法依賴的package包/類
public void setLocation(Location location, double qiblaAngle) {
    if (location == null) return;
    mPrayTimes.setCoordinates(location.getLatitude(), location.getLongitude(), 0);
    mQiblaAngle = qiblaAngle;
    mQiblaTime = mPrayTimes.getQiblaTime();
    LocalTime sunrise = LocalTime.parse(mPrayTimes.getTime(Constants.TIMES_SUNRISE));
    LocalTime sunset = LocalTime.parse(mPrayTimes.getTime(Constants.TIMES_SUNSET));
    LocalTime current = LocalTime.now();

    mShowSun = !(sunset.isBefore(current) || sunrise.isAfter(current));

    mSunriseAngle = Math.toDegrees(getAzimuth(sunrise.toDateTimeToday().getMillis(), location.getLatitude(), location.getLongitude())) - qiblaAngle - 90;
    mSunsetAngle = Math.toDegrees(getAzimuth(sunset.toDateTimeToday().getMillis(), location.getLatitude(), location.getLongitude())) - qiblaAngle - 90;
    mCurrentAngle = Math.toDegrees(getAzimuth(current.toDateTimeToday().getMillis(), location.getLatitude(), location.getLongitude())) - qiblaAngle - 90;
}
 
開發者ID:metinkale38,項目名稱:prayer-times-android,代碼行數:16,代碼來源:QiblaTimeView.java

示例3: 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

示例4: timeConflict

import org.joda.time.LocalTime; //導入方法依賴的package包/類
public static boolean timeConflict(Course c, Course c2){
	String t=c2.getTime().substring(0, c2.getTime().indexOf(':')+3);
	LocalTime courseStart=new LocalTime(Integer.parseInt(t.substring(0, t.indexOf(':'))), Integer.parseInt(t.substring(t.indexOf(':')+1)));
	t=c2.getTime().substring(c2.getTime().indexOf('-')+1);
	t=t.substring(0, t.indexOf(':')+3);
	LocalTime courseEnd=new LocalTime(Integer.parseInt(t.substring(0, t.indexOf(':'))), Integer.parseInt(t.substring(t.indexOf(':')+1)));
	
		t=c.getTime().substring(0, c.getTime().indexOf(':')+3);
		LocalTime cStart=new LocalTime(Integer.parseInt(t.substring(0, t.indexOf(':'))), Integer.parseInt(t.substring(t.indexOf(':')+1)));
		t=c.getTime().substring(c.getTime().indexOf('-')+1);
		t=t.substring(0, t.indexOf(':')+3);
		LocalTime cEnd=new LocalTime(Integer.parseInt(t.substring(0, t.indexOf(':'))), Integer.parseInt(t.substring(t.indexOf(':')+1)));
		
		if(courseStart.equals(cStart) || courseEnd.equals(cEnd)){
			return true;
		}else if(courseStart.isBefore(cStart)){
			if(courseEnd.isAfter(cStart)){
				return true;
			}
		}
		else if(cStart.isBefore(courseStart)){
			if(cEnd.isAfter(courseStart)){
				return true;
			}
		}
	return false;
}
 
開發者ID:mrjones2014,項目名稱:FixedIt,代碼行數:28,代碼來源:Schedule.java

示例5: createBreak

import org.joda.time.LocalTime; //導入方法依賴的package包/類
@RequiresAuthentication(clientName = "default", authorizerName = "admin")
public Result createBreak(int timetrackId, int userId, String from, String to) throws Exception {
    CommonProfile profile = getUserProfile();
    int currentUserId = Integer.parseInt(profile.getId());
    TimeTrack timeTrack = _timeTracking.readTimeTrackById(timetrackId);

    Map<String, String> formData = Form.form().bindFromRequest(
        "starttime",
        "endtime"
    ).data();

    DateTime fromDate = null;
    DateTime toDate = null;

    if (formData.get("starttime") != null && !formData.get("starttime").isEmpty()) {
        fromDate = DateTimeUtils.stringToTime(formData.get("starttime"));
    }
    if (formData.get("endtime") != null && !formData.get("endtime").isEmpty()) {
        toDate = DateTimeUtils.stringToTime(formData.get("endtime"));
    }
    if (fromDate == null || toDate == null) {
        throw new UserException("exceptions.timetracking.error_in_break_form");
    }

    // in case we have a break over midnight (dates from DateTimeUtils.stringToTime() are always equal)
    // IMPORTANT: only add a day, when the timeTrack is also over midnight. otherwise we would accept
    //    from after to because we would bypass from.isBefore(to) validation in Break.class.
    //    also make sure that no wrong inputs are increased one day when
    LocalTime timeTrackStart = timeTrack.getFrom().toLocalTime();
    LocalTime timeTrackEnd = timeTrack.getTo().toLocalTime();
    boolean timeTrackOverMidnight = timeTrackStart.isAfter(timeTrackEnd);
    boolean breakOverMidnight = fromDate.toLocalTime().isAfter(timeTrackStart) && toDate.toLocalTime().isBefore(timeTrackEnd);
    if(timeTrackOverMidnight && breakOverMidnight) {
        toDate = toDate.plusDays(1);
    }

    timeTrack.addBreak(new Break(fromDate, toDate));

    String message = Messages.get("notifications.changed_timetrack",
            profile.getFirstName() + " " + profile.getFamilyName(),
            DateTimeUtils.dateTimeToDateString(timeTrack.getFrom())
    );

    _timeTracking.updateTimeTrack(timeTrack, currentUserId, message);

    return redirect(routes.TimeTrackController.readTimeTracks(userId, from, to));
}
 
開發者ID:peerdavid,項目名稱:ComeAndGo,代碼行數:48,代碼來源:TimeTrackController.java


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