List of usage examples for java.util Calendar compareTo
private int compareTo(long t)
From source file:org.sofun.core.kup.KupImpl.java
@Override public Date getCloseDate() { // Date at which the last betable sport event of the kup will start. final Date d = getLastEventStartDate(); final Calendar ref = Calendar.getInstance(); ref.setTime(d);//from ww w .j av a2 s . c o m ref.add(Calendar.SECOND, -CoreConstants.TIME_TO_BET_BEFORE_EVENT_STARTS); // End date specified by the administrator (i.e. : Sofun Gaming). // For instance, players can be requested to save their predictions 1 // week before the sport event(s) actual starts. // In this case they can only follow the results / loading after // effective end date but cannot save any predictions nor // bet anymore after this date is reached. final Date actualEndDate = getEndDate(); final Calendar actualEndDateRef = Calendar.getInstance(); actualEndDateRef.setTime(actualEndDate); // The effective end date will be the closest date from now. if (actualEndDateRef.compareTo(ref) < 0) { return actualEndDateRef.getTime(); } else { return ref.getTime(); } }
From source file:org.sofun.core.sport.SportsGraphLifeCycleManager.java
/** * Checks sports graph elements (Season, Stage, Round and Game) and * transitioning their status when needed. * //from w w w .j a v a 2s .com * @throws Exception */ // XXX DISABLED // @Schedule(minute = "*/5", hour = "*", persistent = false) public void check() throws Exception { if (!available) { return; } else { available = false; } try { final Calendar ref = getReferenceTime(); log.debug("Reference time for end of predictions " + ref.getTime().toString()); // Check scheduled games: This is important for this manager to // handle the `scheduled` to `on_going` transition (versus feed // provider component). This status conditions the ability for a // player to place a bet. for (TournamentGame game : sports.getTournamentGamesByStatus(TournamentGameStatus.SCHEDULED)) { final Date startDate = game.getStartDate(); if (startDate != null) { final Calendar calStartDate = Calendar.getInstance(); calStartDate.setTime(startDate); if (ref.compareTo(calStartDate) >= 0) { log.info("End of predictions for game with uuid=" + game.getUUID() + " starting @ " + calStartDate.getTime().toString()); game.setGameStatus(TournamentGameStatus.ON_GOING); } } } // Check for games that do not have any status. Let's not assume the // third party provider never does mistakes. for (TournamentGame game : sports.getTournamentGamesByStatus(null)) { final Date startDate = game.getStartDate(); if (startDate != null) { final Calendar calStartDate = Calendar.getInstance(); calStartDate.setTime(startDate); if (ref.compareTo(calStartDate) < 0) { log.info("Marking game with uuid=" + game.getUUID() + " as scheduled. Former status was unknown."); game.setGameStatus(TournamentGameStatus.SCHEDULED); } else { log.info("Marking game with uuid=" + game.getUUID() + " as terminated. Former status was unknown."); game.setGameStatus(TournamentGameStatus.TERMINATED); } } } // Subsequent transitions (closed, cancelled, postponed, etc.) will // he handled by the component implementing the third party // external feed provider (see sofun-platform-opta for instance) // Check rounds: `scheduled` -> `on going` -> `terminated` for (TournamentRound round : sports.getTournamentRoundsByStatus(TournamentRoundStatus.SCHEDULED)) { boolean terminated = true; boolean onGoing = false; if (round.getGames().size() > 0) { for (TournamentGame game : round.getGames()) { final String gameStatus = game.getGameStatus(); if (!(TournamentGameStatus.TERMINATED.equals(gameStatus) || TournamentGameStatus.CANCELLED.equals(gameStatus))) { // One game is still scheduled. Nothing to do. terminated = false; break; } if (TournamentGameStatus.ON_GOING.equals(gameStatus)) { // One game is ongoing and the game is marked as // scheduled. Let's transition round onGoing = true; break; } } if (terminated) { // All games for this round are terminated. Marking // round as terminated. log.info("All games for round w/ UUID=" + String.valueOf(round.getUUID()) + " are marked as terminated. Marking round terminated"); round.setStatus(TournamentRoundStatus.TERMINATED); } if (onGoing) { log.info("At least one game in round w/ UUID=" + String.valueOf(round.getUUID()) + " is marked as ON_GOING. Marking round as ON_GOING"); round.setStatus(TournamentRoundStatus.ON_GOING); } } else { // Handle case of a rounds with no games. (CY, F1, etc.) final Calendar startDate = Calendar.getInstance(); startDate.setTime(round.getStartDate()); if (ref.compareTo(startDate) >= 0 && TournamentRoundStatus.SCHEDULED.equals(round.getStatus())) { log.info("Round w/ UUID=" + String.valueOf(round.getUUID()) + " is marked as ON_GOING."); round.setStatus(TournamentRoundStatus.ON_GOING); } } } // Check rounds: unknown status for (TournamentRound round : sports.getTournamentRoundsByStatus(null)) { boolean onGoing = false; boolean scheduled = false; for (TournamentGame game : round.getGames()) { final String gameStatus = game.getGameStatus(); if (TournamentGameStatus.ON_GOING.equals(gameStatus)) { onGoing = true; break; } else if (TournamentGameStatus.SCHEDULED.equals(gameStatus) || TournamentGameStatus.POSTPONED.equals(gameStatus)) { scheduled = true; } } if (onGoing) { if (!TournamentRoundStatus.ON_GOING.equals(round.getStatus())) { log.info("At least one game in round w/ UUID=" + String.valueOf(round.getUUID()) + " is marked as ON_GOING. Marking round as " + "ON_GOING. Former status was unknown"); round.setStatus(TournamentRoundStatus.ON_GOING); } } else if (scheduled) { if (!TournamentRoundStatus.SCHEDULED.equals(round.getStatus())) { log.info("At least one game in round w/ UUID=" + String.valueOf(round.getUUID()) + " is marked as SCHEDULED. Marking round as " + "SCHEDULED. Former status was unknown"); round.setStatus(TournamentRoundStatus.SCHEDULED); } } else { if (!TournamentRoundStatus.TERMINATED.equals(round.getStatus())) { log.info("No game in round w/ UUID=" + String.valueOf(round.getUUID()) + " is marked as SCHEDULED, ON_GOING or " + "POSPONED Marking round as " + "TERMINATED. Former status was unknown"); round.setStatus(TournamentRoundStatus.TERMINATED); } } } // Check stages: `scheduled` -> `on going` -> `terminated` List<TournamentStage> stages = sports.getTournamentStagesByStatus(TournamentStageStatus.SCHEDULED); stages.addAll(sports.getTournamentStagesByStatus(TournamentStageStatus.ON_GOING)); for (TournamentStage stage : stages) { boolean terminated = true; boolean onGoing = false; for (TournamentRound round : stage.getRounds()) { final String roundStatus = round.getStatus(); if (TournamentRoundStatus.ON_GOING.equals(roundStatus)) { // One round is ongoing and the stage is marked as // scheduled. Let's transition stage terminated = false; onGoing = true; break; } if (!(TournamentRoundStatus.TERMINATED.equals(roundStatus) || TournamentRoundStatus.CANCELLED.equals(roundStatus))) { // One round is still scheduled. Nothing to do. terminated = false; break; } } if (terminated) { // All rounds for this stage are terminated. Marking stage // as terminated. if (!TournamentStageStatus.TERMINATED.equals(stage.getStatus())) { log.info("All rounds for stage w/ UUID=" + String.valueOf(stage.getUUID()) + " are marked as terminated. Marking stage terminated"); stage.setStatus(TournamentStageStatus.TERMINATED); } } if (onGoing) { if (!TournamentStageStatus.ON_GOING.equals(stage.getStatus())) { log.info("At least one round in stage w/ UUID=" + String.valueOf(stage.getUUID()) + " is marked as ON_GOING. Marking stage as ON_GOING"); stage.setStatus(TournamentStageStatus.ON_GOING); } } } // Check stages: unknown status for (TournamentStage stage : sports.getTournamentStagesByStatus(null)) { boolean onGoing = false; boolean scheduled = false; for (TournamentRound round : stage.getRounds()) { final String roundStatus = round.getStatus(); if (TournamentRoundStatus.ON_GOING.equals(roundStatus)) { onGoing = true; break; } else if (TournamentRoundStatus.SCHEDULED.equals(roundStatus) || TournamentRoundStatus.POSTPONED.equals(roundStatus)) { scheduled = true; } } if (onGoing) { log.info("At least one round in stage w/ UUID=" + String.valueOf(stage.getUUID()) + " is marked as ON_GOING. Marking stage as " + "ON_GOING. Former status was unknown"); stage.setStatus(TournamentStageStatus.ON_GOING); } else if (scheduled) { log.info("At least one round in stage w/ UUID=" + String.valueOf(stage.getUUID()) + " is marked as SCHEDULED. Marking stage as " + "SCHEDULED. Former status was unknown"); stage.setStatus(TournamentStageStatus.SCHEDULED); } else { log.info("No round in stage w/ UUID=" + String.valueOf(stage.getUUID()) + " is marked as SCHEDULED, ON_GOING or " + "POSPONED Marking stage as " + "TERMINATED. Former status was unknown"); stage.setStatus(TournamentStageStatus.TERMINATED); } } // Check seasons: `scheduled` -> `on going` -> `terminated` for (TournamentSeason season : sports.getTournamentSeasonsByStatus(TournamentSeasonStatus.SCHEDULED)) { boolean terminated = true; boolean onGoing = false; for (TournamentStage stage : season.getStages()) { final String stageStatus = stage.getStatus(); if (TournamentStageStatus.ON_GOING.equals(stageStatus)) { // One stage is ongoing and the season is marked as // scheduled. Let's transition stage onGoing = true; terminated = false; break; } if (!(TournamentStageStatus.TERMINATED.equals(stageStatus) || TournamentStageStatus.CANCELLED.equals(stageStatus))) { // One stage is still scheduled. Nothing to do. terminated = false; break; } } if (terminated) { // All stages for this stage are terminated. Marking season // as terminated. log.info("All stages for season w/ UUID=" + String.valueOf(season.getUUID()) + " are marked as terminated. Marking season terminated"); season.setStatus(TournamentSeasonStatus.TERMINATED); } if (onGoing) { log.info("At least one stage in season w/ UUID=" + String.valueOf(season.getUUID()) + " is marked as ON_GOING. Marking season as ON_GOING"); season.setStatus(TournamentSeasonStatus.ON_GOING); } } // Check seasons: unknown status for (TournamentSeason season : sports.getTournamentSeasonsByStatus(null)) { boolean onGoing = false; boolean scheduled = false; for (TournamentStage stage : season.getStages()) { final String stageStatus = stage.getStatus(); if (TournamentStageStatus.ON_GOING.equals(stageStatus)) { onGoing = true; break; } else if (TournamentStageStatus.SCHEDULED.equals(stageStatus) || TournamentStageStatus.POSTPONED.equals(stageStatus)) { scheduled = true; } } if (onGoing) { log.info("At least one stage in season w/ UUID=" + String.valueOf(season.getUUID()) + " is marked as ON_GOING. Marking season as " + "ON_GOING. Former status was unknown"); season.setStatus(TournamentSeasonStatus.ON_GOING); } else if (scheduled) { log.info("At least one stage in season w/ UUID=" + String.valueOf(season.getUUID()) + " is marked as SCHEDULED. Marking season as " + "SCHEDULED. Former status was unknown"); season.setStatus(TournamentSeasonStatus.SCHEDULED); } else { log.info("No stage in season w/ UUID=" + String.valueOf(season.getUUID()) + " is marked as SCHEDULED, ON_GOING or " + "POSPONED Marking season as " + "TERMINATED. Former status was unknown"); season.setStatus(TournamentSeasonStatus.TERMINATED); } } } finally { available = true; } }
From source file:no.met.jtimeseries.chart.ChartPlotter.java
private void addDomainGridLinesToPlot(int hourInterval, XYPlot plot) { DateAxis axis = (DateAxis) plot.getDomainAxis(); Calendar currDate = Calendar.getInstance(); currDate.setTime(axis.getMinimumDate()); Calendar maxDate = Calendar.getInstance(); maxDate.setTime(axis.getMaximumDate()); // we do not paint the first domain grid lines since it conflicts with // the axis line boolean first = true; while (currDate.compareTo(maxDate) < 0) { if (first) { first = false;// w w w .ja v a 2 s. co m } else { paintDomainGridLine(currDate, plot); } currDate.add(Calendar.HOUR, hourInterval); } }
From source file:org.sofun.core.prediction.PredictionServiceImpl.java
@Override public boolean isPredictionAllowedOn(TournamentSeason season) { Calendar ref = Calendar.getInstance(); ref.add(Calendar.SECOND, CoreConstants.TIME_TO_BET_BEFORE_EVENT_STARTS); boolean allowed = true; if (season == null) { return false; }// w ww . j a va 2 s. c om if (season.getStartDate() != null) { Calendar seasonStartDate = Calendar.getInstance(); seasonStartDate.setTime(season.getStartDate()); if (ref.compareTo(seasonStartDate) >= 0) { return false; } } // start date may not be announced until the last day. return allowed; }
From source file:nl.strohalm.cyclos.services.elements.CommissionServiceImpl.java
private void unsuspendBrokerCommissionContracts(final Member broker, final BrokerCommission brokerCommission) { final Calendar today = DateHelper.truncate(Calendar.getInstance()); final BrokerCommissionContractQuery query = new BrokerCommissionContractQuery(); query.setBroker(broker);// w ww.ja v a 2s .c om query.setBrokerCommission(brokerCommission); query.setStatus(BrokerCommissionContract.Status.SUSPENDED); final List<BrokerCommissionContract> brokerCommissionContracts = brokerCommissionContractDao.search(query); for (final BrokerCommissionContract brokerCommissionContract : brokerCommissionContracts) { final BrokerCommissionContract.Status statusBeforeSuspension = brokerCommissionContract .getStatusBeforeSuspension(); final Calendar beginOfContract = brokerCommissionContract.getPeriod().getBegin(); final Calendar endOfContract = brokerCommissionContract.getPeriod().getEnd(); if (statusBeforeSuspension == BrokerCommissionContract.Status.ACTIVE) { // If the contract is expired (ends before the beginning of today), close it if (endOfContract.compareTo(today) < 0) { brokerCommissionContract.setStatus(BrokerCommissionContract.Status.CLOSED); } else { brokerCommissionContract.setStatus(BrokerCommissionContract.Status.ACTIVE); } } else if (statusBeforeSuspension == BrokerCommissionContract.Status.ACCEPTED) { // If the contract is expired (ends before the beginning of today), close it if (endOfContract.compareTo(today) < 0) { brokerCommissionContract.setStatus(BrokerCommissionContract.Status.CLOSED); } else if (beginOfContract.compareTo(today) <= 0) { // If the contract begins before today and it was already accepted, activate it brokerCommissionContract.setStatus(BrokerCommissionContract.Status.ACTIVE); } else { // The contract goes back to "ACCEPTED" status brokerCommissionContract.setStatus(BrokerCommissionContract.Status.ACCEPTED); } } else { // If the contract begins before today and was not accepted yet, expire it if (beginOfContract.compareTo(today) <= 0) { brokerCommissionContract.setStatus(BrokerCommissionContract.Status.EXPIRED); } else { brokerCommissionContract.setStatus(BrokerCommissionContract.Status.PENDING); } } brokerCommissionContract.setStatusBeforeSuspension(null); brokerCommissionContractDao.update(brokerCommissionContract); } }
From source file:com.marcohc.robotocalendar.RobotoCalendarView.java
public void updateBackgroundSelectDays() { if (startDay != null && endDay != null) { Calendar auxCalendar = Calendar.getInstance(locale); auxCalendar.setTime(currentCalendar.getTime()); auxCalendar.set(Calendar.DAY_OF_MONTH, 1); auxCalendar.set(Calendar.HOUR_OF_DAY, 0); auxCalendar.set(Calendar.MINUTE, 0); // set minute in hour auxCalendar.set(Calendar.SECOND, 0); // set second in minute auxCalendar.set(Calendar.MILLISECOND, 0); Calendar startCalendar = getCurrentCalendar(); startCalendar.setTime(startDay); Calendar endCalendar = getCurrentCalendar(); endCalendar.setTime(endDay);//ww w. j a va 2 s.co m if (auxCalendar.compareTo(endCalendar) > 0) return; if (auxCalendar.compareTo(startCalendar) > 0) { startCalendar = auxCalendar; if (startCalendar.compareTo(endCalendar) != 0) { ViewGroup startDayOfMonthBackground = getDayOfMonthBackgroundContainer(startCalendar); startDayOfMonthBackground.setBackgroundColor( ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day)); TextView dayOfMonth = getDayOfMonthText(startCalendar); dayOfMonth.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_white)); } int totalDaysInMonth = auxCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); Calendar endDayOnMonthCalendar = Calendar.getInstance(locale); endDayOnMonthCalendar.setTime(auxCalendar.getTime()); endDayOnMonthCalendar.set(Calendar.DATE, totalDaysInMonth); if (endDayOnMonthCalendar.compareTo(endCalendar) < 0) { endCalendar = endDayOnMonthCalendar; ViewGroup endDayOfMonthBackground = getDayOfMonthBackgroundContainer(endCalendar); endDayOfMonthBackground.setBackgroundColor( ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day)); TextView dayOfMonth = getDayOfMonthText(endCalendar); dayOfMonth.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_white)); } else { ViewGroup endDayOfMonthBackground = getDayOfMonthBackgroundContainer(endCalendar); endDayOfMonthBackground.setBackgroundResource(R.drawable.ic_select_right); TextView dayOfMonth = getDayOfMonthText(endCalendar); dayOfMonth .setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day)); ViewGroup dayOfMonthBackground = getDayOfMonthBackground(endCalendar); dayOfMonthBackground.setBackgroundResource(R.drawable.circle); } } else { int totalDaysInMonth = auxCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); Calendar endDayOnMonthCalendar = Calendar.getInstance(locale); endDayOnMonthCalendar.setTime(auxCalendar.getTime()); endDayOnMonthCalendar.set(Calendar.DATE, totalDaysInMonth); if (endDayOnMonthCalendar.compareTo(startCalendar) < 0) return; if (endDayOnMonthCalendar.compareTo(endCalendar) < 0) { endCalendar = endDayOnMonthCalendar; if (startCalendar.compareTo(endCalendar) != 0) { ViewGroup endDayOfMonthBackground = getDayOfMonthBackgroundContainer(endCalendar); endDayOfMonthBackground.setBackgroundColor( ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day)); TextView dayOfMonth = getDayOfMonthText(endCalendar); dayOfMonth .setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_white)); } ViewGroup startDayOfMonthBackground = getDayOfMonthBackgroundContainer(startCalendar); startDayOfMonthBackground.setBackgroundResource(R.drawable.ic_select_left); ViewGroup dayOfMonthBackground = getDayOfMonthBackground(startCalendar); dayOfMonthBackground.setBackgroundResource(R.drawable.circle); } else { int compare = startCalendar.compareTo(endCalendar);//compare startdate and enddate, if they are equal, just draw circle not draw background startdate and enddate ViewGroup startDayOfMonthBackground = getDayOfMonthBackgroundContainer(startCalendar); if (compare != 0) startDayOfMonthBackground.setBackgroundResource(R.drawable.ic_select_left); ViewGroup dayOfMonthBackground = getDayOfMonthBackground(startCalendar); dayOfMonthBackground.setBackgroundResource(R.drawable.circle); ViewGroup endDayOfMonthBackground = getDayOfMonthBackgroundContainer(endCalendar); if (compare != 0) endDayOfMonthBackground.setBackgroundResource(R.drawable.ic_select_right); dayOfMonthBackground = getDayOfMonthBackground(endCalendar); dayOfMonthBackground.setBackgroundResource(R.drawable.circle); TextView dayOfMonth = getDayOfMonthText(endCalendar); dayOfMonth .setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day)); dayOfMonth = getDayOfMonthText(startCalendar); dayOfMonth .setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day)); } } String formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startCalendar.getTime()); int days = getDays(startCalendar, endCalendar); for (int i = 1; i < days; i++) { startCalendar.add(Calendar.DAY_OF_YEAR, 1); ViewGroup dayOfMonthBackground = getDayOfMonthBackgroundContainer(startCalendar); TextView dayOfMonth = getDayOfMonthText(startCalendar); if (dayOfMonth.getVisibility() != View.VISIBLE) continue; dayOfMonth.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_white)); dayOfMonthBackground.setBackgroundColor( ContextCompat.getColor(getContext(), R.color.roboto_calendar_select_day)); } } else { if (startDay != null) { Calendar startDayOnMonthCalendar = Calendar.getInstance(locale); startDayOnMonthCalendar.setTime(currentCalendar.getTime()); startDayOnMonthCalendar.set(Calendar.DAY_OF_MONTH, 1); startDayOnMonthCalendar.set(Calendar.HOUR_OF_DAY, 0); startDayOnMonthCalendar.set(Calendar.MINUTE, 0); // set minute in hour startDayOnMonthCalendar.set(Calendar.SECOND, 0); // set second in minute startDayOnMonthCalendar.set(Calendar.MILLISECOND, 0); Calendar endDayOnMonthCalendar = Calendar.getInstance(locale); endDayOnMonthCalendar.setTime(startDayOnMonthCalendar.getTime()); int totalDaysInMonth = startDayOnMonthCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); endDayOnMonthCalendar.set(Calendar.DATE, totalDaysInMonth); Calendar startCalendar = getCurrentCalendar(); startCalendar.setTime(startDay); if (startCalendar.compareTo(startDayOnMonthCalendar) >= 0 && startCalendar.compareTo(endDayOnMonthCalendar) <= 0) { selectStartDay(startDay); } } } }
From source file:com.jaspersoft.jasperserver.api.engine.scheduling.hibernate.HibernateReportJobsPersistenceService.java
private boolean matchRestriction(Object model, Object value) { try {/*from w w w .ja v a 2 s. co m*/ if (model == null) return true; if (model instanceof Date) { Calendar calendar1 = new GregorianCalendar(); calendar1.setTime((Date) model); calendar1.set(Calendar.SECOND, 0); calendar1.set(Calendar.MILLISECOND, 0); Calendar calendar2 = new GregorianCalendar(); calendar2.setTime((Date) value); calendar2.set(Calendar.SECOND, 0); calendar2.set(Calendar.MILLISECOND, 0); return (calendar1.compareTo(calendar2) == 0); } else if (model instanceof String) return ((String) model).equalsIgnoreCase((String) value); else model.equals(value); return true; } catch (Exception ex) { return false; } }
From source file:org.sofun.core.prediction.PredictionServiceImpl.java
@Override public boolean isPredictionAllowedOn(TournamentGame game) { Calendar ref = Calendar.getInstance(); ref.add(Calendar.SECOND, CoreConstants.TIME_TO_BET_BEFORE_EVENT_STARTS); boolean allowed = true; if (game == null) { return false; }// www. j av a2 s .co m if (!TournamentGameStatus.SCHEDULED.equals(game.getGameStatus())) { return false; } if (game.getStartDate() != null) { Calendar gameStartDate = Calendar.getInstance(); gameStartDate.setTime(game.getStartDate()); if (ref.compareTo(gameStartDate) >= 0) { return false; } } // start date may not be announced until the last day. return allowed; }
From source file:org.sofun.core.prediction.PredictionServiceImpl.java
@Override public boolean isPredictionAllowedOn(TournamentRound round) { Calendar ref = Calendar.getInstance(); ref.add(Calendar.SECOND, CoreConstants.TIME_TO_BET_BEFORE_EVENT_STARTS); boolean allowed = true; if (round == null) { return false; }/*from w ww . j ava2 s .c o m*/ if (!TournamentGameStatus.SCHEDULED.equals(round.getStatus())) { return false; } if (round.getStartDate() != null) { Calendar roundStartDate = Calendar.getInstance(); roundStartDate.setTime(round.getStartDate()); if (ref.compareTo(roundStartDate) >= 0) { return false; } } // start date may not be announced until the last day. return allowed; }
From source file:org.sofun.core.prediction.PredictionServiceImpl.java
@Override public boolean isPredictionAllowedOn(TournamentStage stage) { Calendar ref = Calendar.getInstance(); ref.add(Calendar.SECOND, CoreConstants.TIME_TO_BET_BEFORE_EVENT_STARTS); boolean allowed = true; if (stage == null) { return false; }// ww w . ja v a2s.c om if (!TournamentGameStatus.SCHEDULED.equals(stage.getStatus())) { return false; } if (stage.getStartDate() != null) { Calendar stageStartDate = Calendar.getInstance(); stageStartDate.setTime(stage.getStartDate()); if (ref.compareTo(stageStartDate) >= 0) { return false; } } // start date may not be announced until the last day. return allowed; }