示例#1
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Carpool carpool = (Carpool) o;

    if (capacity != carpool.capacity) return false;
    if (totalCabCharges != carpool.totalCabCharges) return false;
    if (cabType != carpool.cabType) return false;
    if (carpoolBuddies != null
        ? !carpoolBuddies.equals(carpool.carpoolBuddies)
        : carpool.carpoolBuddies != null) return false;
    if (name != null ? !name.equals(carpool.name) : carpool.name != null) return false;
    if (officeETA != null ? !officeETA.equals(carpool.officeETA) : carpool.officeETA != null)
      return false;
    if (officeETD != null ? !officeETD.equals(carpool.officeETD) : carpool.officeETD != null)
      return false;
    if (routePoints != null
        ? !routePoints.equals(carpool.routePoints)
        : carpool.routePoints != null) return false;
    if (startDate != null ? !startDate.equals(carpool.startDate) : carpool.startDate != null)
      return false;
    if (status != carpool.status) return false;

    return true;
  }
示例#2
0
 public LocalDateTime getLocalDateTime(LocalDate selectedDate, LocalTime startTime) {
   return new LocalDateTime(
       selectedDate.getYear(),
       selectedDate.getMonthOfYear(),
       selectedDate.getDayOfMonth(),
       startTime.getHourOfDay(),
       startTime.getMinuteOfHour());
 }
示例#3
0
 /**
  * Gets data from time picker and assigns it to proper time.
  *
  * @param time time to be assigned
  * @param start indicates which time we edits
  */
 public void getTimeFromDialog(LocalTime time, boolean start) {
   // TextView startTime = (TextView) findViewById(R.id.tbTimeStart);
   if (start) {
     startTime = time;
     tbStartTime.setText(time.toString("HH:mm"));
   } else {
     endTime = time;
     tbEndTime.setText(time.toString("HH:mm"));
   }
 }
示例#4
0
 @Override
 public int hashCode() {
   int result = name != null ? name.hashCode() : 0;
   result = 31 * result + (startDate != null ? startDate.hashCode() : 0);
   result = 31 * result + (officeETA != null ? officeETA.hashCode() : 0);
   result = 31 * result + (officeETD != null ? officeETD.hashCode() : 0);
   result = 31 * result + totalCabCharges;
   result = 31 * result + (cabType != null ? cabType.hashCode() : 0);
   result = 31 * result + (status != null ? status.hashCode() : 0);
   result = 31 * result + (carpoolBuddies != null ? carpoolBuddies.hashCode() : 0);
   result = 31 * result + capacity;
   result = 31 * result + (routePoints != null ? routePoints.hashCode() : 0);
   return result;
 }
示例#5
0
 @JsonIgnore
 public boolean isTodaysDosageResponseCaptured() {
   LocalDate today = DateUtil.today();
   LocalDate yesterday = today.minusDays(1);
   LocalTime localNow = DateUtil.now().toLocalTime();
   if (responseLastCapturedDate == null) {
     return false;
   }
   if (responseLastCapturedDate.equals(today)) {
     return true;
   }
   return responseLastCapturedDate.equals(yesterday)
       && new Time(localNow.getHourOfDay(), localNow.getMinuteOfHour()).isBefore(dosageTime);
 }
示例#6
0
  @Test
  public void testTimeConverter() {
    String sql = "select current_time as col1 from (values(0))";

    Time sqlTime = sql2o.createQuery(sql).executeScalar(Time.class);
    assertThat(sqlTime, is(notNullValue()));
    assertTrue(sqlTime.getTime() > 0);

    Date date = sql2o.createQuery(sql).executeScalar(Date.class);
    assertThat(date, is(notNullValue()));

    LocalTime jodaTime = sql2o.createQuery(sql).executeScalar(LocalTime.class);
    assertTrue(jodaTime.getMillisOfDay() > 0);
    assertThat(jodaTime.getHourOfDay(), is(equalTo(new LocalTime().getHourOfDay())));
  }
 public void bind(DataBind b, LocalTime value) throws SQLException {
   if (value == null) {
     b.setNull(Types.TIME);
   } else {
     Time sqlTime = new Time(value.getMillisOfDay());
     b.setTime(sqlTime);
   }
 }
  public void initCountDown() {

    LocalTime timeCurr = new LocalTime();

    LocalTime timeChosen;

    if (sharedPrefs.getString(TimeOption.TIME_STARTED, null) == null) {
      try {
        timeChosen = new LocalTime(sharedPrefs.getString(TimeOption.TIME_CHOSEN, "00:00:00"));
      } catch (Exception ex) {
        timeChosen = new LocalTime("00:00:00");
      }
    } else {

      int valueDiff =
          new LocalTime().getMillisOfDay()
              - new LocalTime(sharedPrefs.getString(TimeOption.TIME_STARTED, "00:00:00"))
                  .getMillisOfDay();

      int valueChosenInMilis =
          new LocalTime(sharedPrefs.getString(TimeOption.TIME_CHOSEN, "00:00:00")).getMillisOfDay();

      if (valueChosenInMilis > valueDiff) {
        valueDiff = valueChosenInMilis - valueDiff;
      } else {
        valueDiff = 0;
      }

      timeChosen = LocalTime.fromMillisOfDay(valueDiff);
    }

    int period = (timeCurr.getMillisOfDay() + timeChosen.getMillisOfDay());

    period -= timeCurr.getMillisOfDay();

    if (period > 0) {
      LocalTime time = new LocalTime().plusMillis(period);
      txtAlarmDone.setText(time.toString());
      txtAlarmPre.setText(time.minusMinutes(1).toString());
      /**
       * txtAlarmDone.setText("Alarm 1" +
       * DateTimeFormat.forPattern("HH:mm:ss").parseLocalTime(time.toString()).toString());
       * txtAlarmPre.setText("Alarm 2" +
       * DateTimeFormat.forPattern(time.minusMinutes(1).toString()).toString());
       */
    }

    startCountDown(period);
  }
 @Test
 public void builderShouldBuildConfigurationWhenRequiredFieldsAreProvided() {
   SchedulingConfiguration configuration =
       SchedulingConfiguration.builder()
           .time(LocalTime.parse("13:23"))
           .recurrence(ArchiveRecurrence.daily())
           .build();
   assertThat(configuration.getRepeatKind()).isEqualTo(RepeatKind.DAILY);
   assertThat(configuration.getHour()).isEqualTo(13);
   assertThat(configuration.getMinute()).isEqualTo(23);
 }
  @Override
  public List<UnidadeIndiceOEE> gerarUnidadesIndiceOEE(
      IndiceOEEPorHoraFilter filter, LocalDateTime dtHrInicio, LocalDateTime dtHrFim) {
    if (dtHrFim == null) {
      LocalTime horaAtual = new LocalTime();
      dtHrFim =
          new LocalDate()
              .toLocalDateTime(
                  new LocalTime(horaAtual.getHourOfDay(), horaAtual.getMinuteOfHour(), 0, 0));
    }
    List<UnidadeIndiceOEE> result = new ArrayList<UnidadeIndiceOEE>();

    int year = dtHrInicio.getYear();
    int month = dtHrInicio.getMonthOfYear();
    int day = dtHrInicio.getDayOfMonth();
    int hour = dtHrInicio.getHourOfDay();

    LocalDateTime dtHr = new LocalDateTime(year, month, day, hour, 0, 0, 0);

    while (dtHr.isBefore(dtHrFim)) {
      if (dtHr.toLocalDate().equals(filter.getDt())) {

        UnidadeIndiceOEE unidade = new UnidadeIndiceOEE();
        unidade.setInicio(dtHr);
        unidade.setFim(dtHr.plusMinutes(59));
        updateId(unidade);

        LocalDateTime inicio = dtHrInicio.isAfter(dtHr) ? dtHrInicio : unidade.getInicio();
        LocalDateTime fim = dtHr.plusHours(1);
        fim = dtHrFim.isAfter(fim) ? fim : dtHrFim;
        Integer tempoUtilMinutos = DateUtils.getDiferencaEmMinutos(inicio, fim);
        unidade.setTempoUtilMinutos(tempoUtilMinutos);

        result.add(unidade);
      }
      dtHr = dtHr.plusHours(1);
    }

    return result;
  }
示例#11
0
 /**
  * @param from
  * @param to
  * @param offsetMinutes
  * @return
  */
 private Pair<Set<LocalTime>, Set<LocalTime>> getTimeOptions(
     DateTime from, DateTime to, int offsetMinutes) {
   Set<LocalTime> first = new TreeSet<LocalTime>();
   Set<LocalTime> second = new TreeSet<LocalTime>();
   if (from == null || to == null) {
     return new Pair<Set<LocalTime>, Set<LocalTime>>(first, second);
   }
   LocalTime startTime = from.toLocalTime();
   from = from.plusMinutes(offsetMinutes);
   int minuteInterval = from.getMinuteOfHour() % 15;
   from = from.plusMinutes(minuteInterval == 0 ? 0 : 15 - minuteInterval);
   while (!from.isAfter(to)) {
     LocalTime nextTime = from.toLocalTime();
     if (!nextTime.isAfter(startTime)) {
       second.add(nextTime);
     } else {
       first.add(nextTime);
     }
     from = from.plusMinutes(15);
   }
   return new Pair<Set<LocalTime>, Set<LocalTime>>(first, second);
 }
示例#12
0
  public static String doTheActualFun() {
    int minutesLeft = 0;
    final LocalTime now = new LocalTime();

    if (hardcodedTimes[hardcodedTimes.length - 1].compareTo(now) <= 0) {
      return makeItNicer(-1);
    }

    LocalTime tmpLocalTimeCalculated;

    for (final LocalTime hardcodedTime : hardcodedTimes) {
      if (hardcodedTime.compareTo(now) >= 0) {
        tmpLocalTimeCalculated =
            hardcodedTime.minusHours(now.getHourOfDay()).minusMinutes(now.getMinuteOfHour());
        minutesLeft =
            tmpLocalTimeCalculated.getHourOfDay() * 60 + tmpLocalTimeCalculated.getMinuteOfHour();
        break;
      }
    }

    return makeItNicer(minutesLeft);
  }
示例#13
0
  public void transfer(Account source, Account target, double amount) {
    if (!timeService.isServiceAvailable(LocalTime.now())) {
      return;
    }

    double sourceBalance = source.getBalance();
    double deductAmount = amount + policy.getFee(amount);
    double newSourceBalance = sourceBalance - deductAmount;
    if (amount <= this.getMinimumAmount() || amount <= 0) {
      throw new IllegalAmountException();
    } else if (sourceBalance >= deductAmount) {
      source.setBalance(newSourceBalance);
      target.setBalance(amount);
    } else {
      throw new InsufficientFundException();
    }
  }
示例#14
0
  @Test
  public void registerNewUser() {
    // test data
    String newUser = "******";
    String newUserEmail = "@test.ua";
    String newUserPassword;
    String newUserZip = "40211";
    boolean privacyPolicyOfNewUserName = true;

    // prepare test data
    String now = LocalTime.now().toString("HHmmssSSS");
    newUserEmail = newUser + now + newUserEmail;
    newUserPassword = newUser + now;

    openNascarMainPage();
    register(newUserEmail, newUserPassword, newUserZip, privacyPolicyOfNewUserName);
    logOutFromNascarMainPage();
  }
示例#15
0
  public void checkForBookedCourts(
      TimeSlot timeSlot, List<Booking> confirmedBookings, Boolean preventOverlapping) {
    LocalTime startTime = timeSlot.getStartTime();
    LocalTime endTime = timeSlot.getEndTime();

    for (Booking booking : confirmedBookings) {

      if (timeSlot.getDate().equals(booking.getBookingDate())) {
        LocalTime bookingStartTime = booking.getBookingTime();
        LocalTime bookingEndTime = bookingStartTime.plusMinutes(booking.getDuration().intValue());
        Boolean addBooking = false;
        if (preventOverlapping) {
          if (startTime.isBefore(bookingEndTime)) {
            if (endTime.isAfter(bookingStartTime)) {
              addBooking = true;
            }
          }
        } else {
          // for displaying allocations
          if (startTime.compareTo(bookingStartTime) >= 0) {
            if (endTime.compareTo(bookingEndTime) <= 0) {
              addBooking = true;
            }
          }
        }
        if (addBooking) {
          Offer offer = booking.getOffer();
          for (Offer timeSlotOffer : timeSlot.getConfig().getOffers()) {
            if (offer.equals(timeSlotOffer)) {
              timeSlot.addBooking(booking);
              break;
            }
          }
        }
      }
    }
  }
@Entity
public class Item extends play.db.ebean.Model implements ChatEntry {
  @Id @GeneratedValue public Long internalId;

  @OneToOne public User user;

  public LocalTime timestamp = LocalTime.now();

  @Required
  @MaxLength(140)
  public String message;

  public Item() {}

  public Item(User user, LocalTime timestamp, String message) {
    this.user = user;
    this.timestamp = timestamp;
    this.message = message;
  }

  public LocalTime timestamp() {
    return timestamp;
  }
}
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   Log.i(TAG, "On create view...");
   // Inflate the layout for this fragment
   LocalTime time = LocalTime.now();
   if (getArguments() != null) {
     time = new DateTime(getArguments().getLong(ARG_TIME)).toLocalTime();
   }
   View view = inflater.inflate(R.layout.fragment_time_picker, container, false);
   mTimePicker = (TimePicker) view.findViewById(R.id.time_picker);
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
     mTimePicker.setHour(time.getHourOfDay());
     mTimePicker.setMinute(time.getMinuteOfHour());
   } else {
     mTimePicker.setCurrentHour(time.getHourOfDay());
     mTimePicker.setCurrentMinute(time.getMinuteOfHour());
   }
   return view;
 }
 @Test(expected = IllegalStateException.class)
 public void builderShouldThrowWhenRepeatKindIsNotProvided() {
   SchedulingConfiguration.builder().time(LocalTime.parse("10:22")).build();
 }
 @Test(expected = IllegalArgumentException.class)
 public void builderShouldThrowWhenTimeHasMillis() {
   SchedulingConfiguration.builder().time(LocalTime.parse("12:22:00.552")).build();
 }
示例#20
0
文件: Time.java 项目: motech/motech
 /**
  * Constructor.
  *
  * @param localTime the time to be stored, not null
  */
 public Time(LocalTime localTime) {
   this(localTime.getHourOfDay(), localTime.getMinuteOfHour());
 }
示例#21
0
 @Override
 public LocalTime now() {
   return LocalTime.now();
 }
示例#22
0
 /**
  * Creates a new LocalTime-valued OData property with {@link EdmSimpleType#TIME}
  *
  * @param name the property name
  * @param value the property value
  * @return a new OData property instance
  */
 public static OProperty<LocalTime> time(String name, Calendar value) {
   return new Impl<LocalTime>(
       name, EdmSimpleType.TIME, value != null ? LocalTime.fromCalendarFields(value) : null);
 }
示例#23
0
 private void timeCalculate() {
   LocalTime localTime = LocalTime.now();
   this.dayMinute = localTime.getHourOfDay() * 60 + localTime.getMinuteOfHour();
 }
示例#24
0
 private static LocalTime parseTime(String value) {
   return LocalTime.parse(value);
 }
示例#25
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_event);

    InternetConnectionService service = new InternetConnectionService(AddEventActivity.this);
    if (!service.isInternetConnection()) {
      ModalService.ShowNoConnetionError(AddEventActivity.this);
      return;
    }

    tbStartDate = (TextView) findViewById(R.id.tbStartDate);
    tbEndDate = (TextView) findViewById(R.id.tbEndDate);
    tbStartTime = (TextView) findViewById(R.id.tbStartTime);
    tbEndTime = (TextView) findViewById(R.id.tbEndTime);
    btnAddFriends = (TextView) findViewById(R.id.btnFriends);
    btnSaveEvent = (TextView) findViewById(R.id.btnSave);
    tbTitle = (TextView) findViewById(R.id.tbEventTitle);
    tbPlace = (TextView) findViewById(R.id.tbPlace);
    tbDesc = (TextView) findViewById(R.id.tbDesc);

    addedUsers = new ArrayList<>();
    endDate = new LocalDate();
    startDate = new LocalDate();
    startTime = new LocalTime();
    endTime = new LocalTime();

    String eventId = getIntent().getStringExtra("eventId");
    if (eventId != null) {
      final ProgressDialog dlg = new ProgressDialog(AddEventActivity.this);
      dlg.setTitle("Please wait.");
      dlg.setMessage("Searching event.  Please wait.");
      dlg.show();

      ParseQuery<ParseEvent> query = ParseQuery.getQuery("Event");
      query.getInBackground(
          eventId,
          new GetCallback<ParseEvent>() {
            @Override
            public void done(ParseEvent object, ParseException e) {
              if (e == null) {
                loadedEvent = object;

                tbTitle.setText(loadedEvent.getTitle());
                tbPlace.setText(loadedEvent.getPlace());
                tbDesc.setText(loadedEvent.getDescription());

                endDate = loadedEvent.getEndDate().toLocalDate();
                startDate = loadedEvent.getStartDate().toLocalDate();
                startTime = loadedEvent.getEndDate().toLocalTime();
                endTime = loadedEvent.getEndDate().toLocalTime();

                btnSaveEvent.setText("SAVE EVENT");

                try {
                  addedUsers = loadedEvent.getUsers();
                } catch (ParseException e1) {
                  ModalService.ShowErrorModal(
                      "Error occured while proceding users!", AddEventActivity.this);
                  finish();
                }
                dlg.dismiss();
              } else {
                dlg.dismiss();
                ModalService.ShowErrorModal("There is no such event!", AddEventActivity.this);
                finish();
              }
            }
          });
    }

    tbStartDate.setText(startDate.toString("dd/MM/yyyy"));
    tbEndDate.setText(endDate.toString("dd/MM/yyyy"));
    tbStartTime.setText(startTime.toString("HH:mm"));
    tbEndTime.setText(endTime.toString("HH:mm"));

    setOnClickListeners();
  }
public class Application extends Controller {

  public static Result index() {
    String email = session().get("email");
    if (email != null) {
      return redirect(routes.Chats.allChats());
    } else {
      return unauthorized(views.html.login.render());
    }
  }

  public static Result login() {
    return ok(views.html.login.render());
  }

  public static Result logout() {
    session().clear();
    return ok(views.html.login.render());
  }

  public static Result enter() {
    Map<String, String[]> params;
    params = request().body().asFormUrlEncoded();

    String email = params.get("email")[0];
    User user = User.find.byId(email);
    if (user == null) {
      return redirect(routes.Application.login());
    } else {
      session("email", email);
      return redirect(routes.Chats.allChats());
    }
  }

  public static LocalDate today = LocalDate.now();
  public static LocalDate yesterday = today.minus(Days.ONE);

  public static Chat chat11 =
      new Chat(
          yesterday,
          1,
          asList(
              new Item(SampleUsers.get.me, LocalTime.now(), "Hello!"),
              new Item(SampleUsers.get.robin, LocalTime.now(), "Hi!"),
              new Item(SampleUsers.get.me, LocalTime.now(), "Fine?"),
              new Item(SampleUsers.get.robin, LocalTime.now(), "Yes")),
          new ArrayList<Image>());
  // later on
  public static Chat chat12 =
      new Chat(
          yesterday,
          2,
          asList(
              new Item(SampleUsers.get.me, LocalTime.now(), "It's hot today!"),
              new Item(SampleUsers.get.robin, LocalTime.now(), "Indeed...")),
          new ArrayList<Image>());

  public static Chat chat21 =
      new Chat(
          today,
          1,
          asList(
              new Item(SampleUsers.get.me, LocalTime.now(), "Hello!"),
              new Item(SampleUsers.get.me, LocalTime.now(), "Youhou?"),
              new Item(SampleUsers.get.noOne, LocalTime.now(), "...")),
          new ArrayList<Image>());
  public static Chat chat22 =
      new Chat(
          today,
          2,
          asList(
              new Item(SampleUsers.get.me, LocalTime.now(), "Ding ding!"),
              new Item(SampleUsers.get.me, LocalTime.now(), "Poueeeeeeeeeet?"),
              new Item(SampleUsers.get.noOne, LocalTime.now(), "...")),
          new ArrayList<Image>());

  public static Chat chat23 =
      new Chat(
          today,
          3,
          asList(
              new Item(SampleUsers.get.me, LocalTime.now(), "No one?"),
              new Item(SampleUsers.get.noOne, LocalTime.now(), "Yes?")),
          new ArrayList<Image>());

  public static Result sample() {

    return ok(sample.render("Chat Archives", asList(chat23, chat11, chat21, chat12, chat22)));
  }
}
示例#27
0
  public OfferDurationPrice getOfferDurationPrice(
      LocalDate selectedDate, LocalTime selectedTime, Offer selectedOffer)
      throws CalendarConfigException {
    List<CalendarConfig> configs = calendarConfigDAO.findFor(selectedDate);
    List<Booking> confirmedBookings = bookingDAO.findBlockedBookingsForDate(selectedDate);

    // convert to required data structure
    Map<Offer, List<CalendarConfig>> offerConfigMap = new HashMap<>();
    for (CalendarConfig config : configs) {
      for (Offer offer : config.getOffers()) {
        if (offer.equals(selectedOffer)) {
          List<CalendarConfig> list = offerConfigMap.get(offer);
          if (list == null) {
            list = new ArrayList<>();
          }
          list.add(config);

          // sort by start time
          Collections.sort(list);
          offerConfigMap.put(offer, list);
        }
      }
    }

    OfferDurationPrice offerDurationPrices = null;

    Iterator<Map.Entry<Offer, List<CalendarConfig>>> iterator =
        offerConfigMap.entrySet().iterator();
    // for every offer
    while (iterator.hasNext()) {
      Map.Entry<Offer, List<CalendarConfig>> entry = iterator.next();
      Offer offer = entry.getKey();
      List<CalendarConfig> configsForOffer = entry.getValue();

      // make sure the first configuration starts before the requested booking time
      if (selectedTime.compareTo(configsForOffer.get(0).getStartTime()) < 0) {
        continue;
      }

      LocalDateTime endTime = null;
      Integer duration = configsForOffer.get(0).getMinDuration();
      BigDecimal pricePerMinute;
      BigDecimal price = null;
      CalendarConfig previousConfig = null;
      Map<Integer, BigDecimal> durationPriceMap = new TreeMap<>();
      Boolean isContiguous = true;
      for (CalendarConfig config : configsForOffer) {

        // make sure there is no gap between calendar configurations
        if (endTime == null) {
          // first run
          endTime =
              getLocalDateTime(selectedDate, selectedTime).plusMinutes(config.getMinDuration());
        } else {
          // break if there are durations available and calendar configs are not contiguous
          if (!durationPriceMap.isEmpty()) {
            // we substract min interval before the comparison as it has been added during the last
            // iteration
            LocalDateTime configStartDateTime =
                getLocalDateTime(selectedDate, config.getStartTime());
            if (!endTime.minusMinutes(config.getMinInterval()).equals(configStartDateTime)) {
              break;
            }
          }
        }

        Integer interval = config.getMinInterval();

        pricePerMinute = getPricePerMinute(config);

        // as long as the endTime is before the end time configured in the calendar
        LocalDateTime configEndDateTime = getLocalDateTime(selectedDate, config.getEndTime());
        while (endTime.compareTo(configEndDateTime) <= 0) {
          TimeSlot timeSlot = new TimeSlot();
          timeSlot.setDate(selectedDate);
          timeSlot.setStartTime(selectedTime);
          timeSlot.setEndTime(endTime.toLocalTime());
          timeSlot.setConfig(config);
          Long bookingSlotsLeft = getBookingSlotsLeft(timeSlot, offer, confirmedBookings);

          // we only allow contiguous bookings for any given offer
          if (bookingSlotsLeft < 1) {
            isContiguous = false;
            break;
          }

          if (price == null) {
            // see if previousConfig endTime - minInterval matches the selected time. if so, take
            // half of the previous config price as a basis
            if (previousConfig != null
                && previousConfig
                    .getEndTime()
                    .minusMinutes(previousConfig.getMinInterval())
                    .equals(selectedTime)) {
              BigDecimal previousConfigPricePerMinute = getPricePerMinute(previousConfig);
              price =
                  previousConfigPricePerMinute.multiply(
                      new BigDecimal(previousConfig.getMinInterval()), MathContext.DECIMAL128);
              price =
                  price.add(
                      pricePerMinute.multiply(
                          new BigDecimal(duration - previousConfig.getMinInterval()),
                          MathContext.DECIMAL128));
            } else {
              price =
                  pricePerMinute.multiply(
                      new BigDecimal(duration.toString()), MathContext.DECIMAL128);
            }
          } else {
            // add price for additional interval
            price =
                price.add(
                    pricePerMinute.multiply(
                        new BigDecimal(interval.toString()), MathContext.DECIMAL128));
          }
          price = price.setScale(2, RoundingMode.HALF_EVEN);
          durationPriceMap.put(duration, price);

          // increase the duration by the configured minimum interval and determine the new end time
          // for the next iteration
          duration += interval;
          endTime = endTime.plusMinutes(interval);
        }

        if (!durationPriceMap.isEmpty()) {
          OfferDurationPrice odp = new OfferDurationPrice();
          odp.setOffer(offer);
          odp.setDurationPriceMap(durationPriceMap);
          odp.setConfig(config);
          offerDurationPrices = odp;
        }

        if (!isContiguous) {
          // we only allow coniguous bookings for one offer. process next offer
          //                    previousConfig = null;
          break;
        }
        previousConfig = config;
      }
    }
    return offerDurationPrices;
  }
示例#28
0
 public boolean wirdBestellt(int vorhandeneMenge, LocalTime time, String wochentag) {
   return time.isBefore(bestellschluss.bestellschluss())
       && vorhandeneMenge <= mindestbestand.mindestbestandFuer(wochentag)
       && !bestellungUnterwegs;
 }
示例#29
0
 @Override
 public String marshal(LocalTime localTime) throws Exception {
   return localTime.toString();
 }
  public static Result index() {
    DateTime today = DateTime.now();
    DateTime yesterday = today.minus(Days.ONE);

    Chat chat11 =
        new Chat(
            yesterday,
            1,
            asList(
                new Item("me", LocalTime.now(), "Hello!"),
                new Item("other", LocalTime.now(), "Hi!"),
                new Item("me", LocalTime.now(), "Fine?"),
                new Item("other", LocalTime.now(), "Yes")));
    // later on
    Chat chat12 =
        new Chat(
            yesterday,
            2,
            asList(
                new Item("me", LocalTime.now(), "It's hot today!"),
                new Item("other", LocalTime.now(), "Indeed...")));

    Chat chat21 =
        new Chat(
            today,
            1,
            asList(
                new Item("me", LocalTime.now(), "Hello!"),
                new Item("me", LocalTime.now(), "Youhou?"),
                new Item("no-one", LocalTime.now(), "...")));
    Chat chat22 =
        new Chat(
            today,
            2,
            asList(
                new Item("me", LocalTime.now(), "Ding ding!"),
                new Item("me", LocalTime.now(), "Poueeeeeeeeeet?"),
                new Item("no-one", LocalTime.now(), "...")));

    Chat chat23 =
        new Chat(
            today,
            3,
            asList(
                new Item("me", LocalTime.now(), "No one?"),
                new Item("no-one", LocalTime.now(), "Yes?")));

    return ok(index.render("It Works!", asList(chat23, chat11, chat21, chat12, chat22)));
  }