コード例 #1
0
  private Fixture saveFixtureForNow(LeagueSeason leagueSeason, Date date) {
    Calendar now = Calendar.getInstance();
    now.setTime(date);
    now.add(Calendar.MINUTE, -15);
    Date start = now.getTime();
    now.add(Calendar.HOUR_OF_DAY, 2);
    Date end = now.getTime();
    Fixture fixture = new Fixture();
    fixture.setLeagueSeason(leagueSeason);
    fixture.setStartDate(start);
    fixture.setEndDate(end);
    fixtureService.saveFixture(fixture);

    // Save some other past fixtures too on other days
    Calendar past = Calendar.getInstance();
    past.setTime(now.getTime());
    for (int i = 0; i < 5; i++) {
      past.add(Calendar.DAY_OF_YEAR, -i);
      past.set(Calendar.HOUR_OF_DAY, i);
      Date s = past.getTime();
      past.add(Calendar.HOUR_OF_DAY, 2);
      Date e = past.getTime();
      Fixture f = new Fixture();
      f.setLeagueSeason(leagueSeason);
      f.setStartDate(s);
      f.setEndDate(e);
      fixtureService.saveFixture(f);
    }

    // Save some other future fixtures too on other days
    Calendar future = Calendar.getInstance();
    future.setTime(now.getTime());
    for (int i = 1; i <= 5; i++) {
      future.add(Calendar.DAY_OF_YEAR, i);
      future.set(Calendar.HOUR_OF_DAY, i);
      Date s = future.getTime();
      future.add(Calendar.HOUR_OF_DAY, 2);
      Date e = future.getTime();
      Fixture f = new Fixture();
      f.setLeagueSeason(leagueSeason);
      f.setStartDate(s);
      f.setEndDate(e);
      fixtureService.saveFixture(f);
    }

    return fixture;
  }
コード例 #2
0
 private void saveClosestFixture(Fixture fixture) {
   Calendar now = Calendar.getInstance();
   now.setTime(fixture.getStartDate());
   now.add(Calendar.HOUR_OF_DAY, -1);
   Date end = now.getTime();
   now.add(Calendar.HOUR_OF_DAY, -2);
   Date start = now.getTime();
   fixture.setStartDate(start);
   fixture.setEndDate(end);
   fixtureService.saveFixture(fixture);
 }