@Override
  protected DateTime fromConvertedColumns(Object[] convertedColumns) {

    LocalDateTime datePart = (LocalDateTime) convertedColumns[0];
    DateTimeZoneWithOffset offset = (DateTimeZoneWithOffset) convertedColumns[1];

    DateTime result;

    if (datePart == null) {
      result = null;
    } else {
      result =
          datePart.toDateTime(
              databaseZone == null ? offset.getStandardDateTimeZone() : databaseZone);

      if (databaseZone != null) {
        result = result.withZone(offset.getStandardDateTimeZone());
      }
    }

    // Handling DST rollover
    if (result != null
        && offset.getOffsetDateTimeZone() != null
        && offset.getStandardDateTimeZone().getOffset(result)
            > offset.getOffsetDateTimeZone().getOffset(result)) {
      return result.withLaterOffsetAtOverlap();
    }

    return result;
  }
Exemplo n.º 2
0
  @Override
  public boolean equals(Object o) {
    if (o == this) return true;
    if (!(o instanceof Employee)) return false;
    Employee e = (Employee) o;

    return lastName.equalsIgnoreCase(e.lastName)
        && firstName.equalsIgnoreCase(e.firstName)
        && (title == null ? e.title == null : title.equalsIgnoreCase(e.title))
        && (titleCourtesy == null
            ? e.titleCourtesy == null
            : titleCourtesy.equalsIgnoreCase(e.titleCourtesy))
        && (birthDate == null ? e.birthDate == null : birthDate.equals(e.birthDate))
        && (hireDate == null ? e.hireDate == null : hireDate.equals(e.hireDate))
        && (address == null ? e.address == null : address.equalsIgnoreCase(e.address))
        && (city == null ? e.city == null : city.equalsIgnoreCase(e.city))
        && (region == null ? e.region == null : region.equalsIgnoreCase(e.region))
        && (postalCode == null ? e.postalCode == null : postalCode.equalsIgnoreCase(e.postalCode))
        && (country == null ? e.country == null : country.equalsIgnoreCase(e.country))
        && (homePhone == null ? e.homePhone == null : homePhone.equalsIgnoreCase(e.homePhone))
        && (extension == null ? e.extension == null : extension.equalsIgnoreCase(e.extension))
        && Arrays.equals(photo, e.photo)
        && (notes == null ? e.notes == null : notes.equalsIgnoreCase(e.notes))
        && (reportsTo == null ? e.reportsTo == null : reportsTo.equals(e.reportsTo))
        && (photoPath == null ? e.photoPath == null : photoPath.equalsIgnoreCase(e.photoPath));
  }
Exemplo n.º 3
0
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
      // Use the current date as the default date in the picker
      int year = 0;
      int month = 0;
      int day = 0;
      /*if (userBirthdate != null) {
          year = userBirthdate.getYear();
          month = userBirthdate.getMonthOfYear() - 1;
          day = userBirthdate.getDayOfMonth();
      } else {*/
      LocalDateTime now = LocalDateTime.now();
      year = now.getYear();
      month = now.getMonthOfYear();
      day = now.getDayOfMonth();
      // }

      DatePickerDialog dateDlg = new DatePickerDialog(getActivity(), this, year, month, day);
      dateDlg.setMessage(getString(R.string.add_date_dialog_title));
      Calendar calendar = Calendar.getInstance();
      calendar.set(Calendar.MONTH, calendar.getActualMaximum(Calendar.MONTH));
      calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
      // dateDlg.getDatePicker().setMaxDate(calendar.getTimeInMillis());

      // Create a new instance of DatePickerDialog and return it
      return dateDlg;
    }
 @Override
 public String convertToString(Map context, Object output) {
   if (output != null && output instanceof LocalDateTime) {
     LocalDateTime result = (LocalDateTime) output;
     return result.toString();
   }
   return null;
 }
 private void assertThatVersionCreationInfoAre(
     Document document, String userId, LocalDateTime dateTime) {
   assertThat(document.getCreationDate().getTime()).isEqualToIgnoringMillis(dateTime.toDate());
   assertThat(document.getCreatedBy()).isEqualTo(userId);
   assertThat(document.getLastModificationDate().getTime())
       .isEqualToIgnoringMillis(dateTime.toDate());
   assertThat(document.getLastModifiedBy()).isEqualTo(userId);
 }
 public List<GameEntity> findGameOnComing() {
   LocalDateTime today = LocalDate.now().toLocalDateTime(new LocalTime(0, 0));
   return getSession()
       .createCriteria(GameEntity.class)
       .setFetchMode("odds", FetchMode.SELECT)
       .add(Restrictions.between("gameTime", today, today.plusDays(3)))
       .list();
 }
Exemplo n.º 7
0
  @Override
  public int compare(LogEvent o1, LogEvent o2) {
    LocalDateTime t1 = o1.getTime();
    LocalDateTime t2 = o2.getTime();

    if (t1.isBefore(t2)) return 1;
    else if (t1.isAfter(t2)) return -1;
    return 0;
  }
 public List<GameEntity> findFinishedGameToday() {
   LocalDateTime today = LocalDate.now().toLocalDateTime(new LocalTime(0, 0));
   Criterion isEnd = Restrictions.eq("isEnd", true);
   Criterion gameStatus = Restrictions.eq("gameStatus", 2L);
   return getSession()
       .createCriteria(GameEntity.class)
       .setFetchMode("odds", FetchMode.SELECT)
       .add(Restrictions.between("gameTime", today, today.plusDays(1)))
       .add(Restrictions.or(isEnd, gameStatus))
       .list();
 }
Exemplo n.º 9
0
  public static String weekDayOfBirthday(String birthday, String year) {
    // напишите тут ваш код

    DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("dd.MM.yyyy");
    LocalDateTime localDateTime = dateTimeFormatter.parseLocalDateTime(birthday);
    localDateTime = localDateTime.withYear(Integer.valueOf(year));

    return DateTimeFormat.forStyle("FF")
        .withLocale(Locale.ITALY)
        .print(localDateTime)
        .split(" ")[0];
  }
  // 找出當天比賽所有的投注一個list 是一場比賽的投注集合,list<list...>是多場比賽的投注集合
  public List<GameEntity> findGameByLocalDate(LocalDate gameTime) {
    LocalDateTime gameTimeLocalDateTime = gameTime.toLocalDateTime(new LocalTime(0, 0));

    Criterion lessEqualGameTime =
        Restrictions.between("gameTime", gameTimeLocalDateTime, gameTimeLocalDateTime.plusDays(1));
    return getSession()
        .createCriteria(GameEntity.class)
        .setFetchMode("odds", FetchMode.SELECT)
        .add(lessEqualGameTime)
        /*.setProjection(Projections.property("odds"))*/
        .list();
  }
 public List<GameEntity> findByNearDays(LocalDateTime gameTime) {
   return getSession()
       .createCriteria(GameEntity.class)
       .setFetchMode("odds", FetchMode.SELECT)
       .add(Restrictions.between("gameTime", gameTime, gameTime.plusDays(1)))
       .list();
 }
Exemplo n.º 12
0
 private static LocalDateTime extractLocatDateTime(JsonElement jsonElement) {
   if (jsonElement == null || jsonElement.isJsonNull()) {
     return null;
   } else {
     return LocalDateTime.parse(jsonElement.getAsString().replace(' ', 'T'));
   }
 }
Exemplo n.º 13
0
  @Override
  public Object getValue(Class<?> type) {

    SingleSelectionSpinner<DayToSelect> daySelector =
        (SingleSelectionSpinner<DayToSelect>) findViewById(R.id.datePicker1);
    SingleSelectionSpinner<HourToSelect> hourSelector =
        (SingleSelectionSpinner<HourToSelect>) findViewById(R.id.timePicker1);

    if (daySelector.getSelectedItem() != null && hourSelector.getSelectedItem() != null) {
      LocalDateTime date = daySelector.getSelectedItem().getDate();

      date = date.withHourOfDay(hourSelector.getSelectedItem().getHour());

      return date.toDate();
    }
    return null;
  }
  private void encode(
      UIInput year,
      UIInput month,
      UIInput day,
      UIInput hour,
      UIInput min,
      LocalDateTime localDateTime) {
    if (localDateTime == null) {
      return;
    }

    year.setValue(normalize(localDateTime.getYear()));
    month.setValue(normalize(localDateTime.getMonthOfYear()));
    day.setValue(normalize(localDateTime.getDayOfMonth()));
    hour.setValue(normalize(localDateTime.getHourOfDay()));
    min.setValue(normalize(localDateTime.getMinuteOfHour()));
  }
 @Test
 public void testIfServiceAddsIdeaToWisdomWall() throws UserException {
   testIdea = new Idea("author", "*****@*****.**", "idea", LocalDateTime.now().toString());
   when(wisdomWallService.addIdeaToWisdomWall(any(String.class), any(String.class)))
       .thenReturn(testIdea);
   assertEquals(
       wisdomWallService.addIdeaToWisdomWall(any(String.class), any(String.class)), testIdea);
 }
Exemplo n.º 16
0
 @BeforeClass
 public static void setUpClass() throws Exception {
   date = new LocalDateTime(2014, 11, 10, 16, 52, 10);
   items = new ArrayList<>();
   items.add(new MetricItem(date, 3, 4, 6, 7, 9, 9, 1, 3));
   items.add(new MetricItem(date.plusMinutes(10), 1, 3, 10, 6, 2, 8, 3, 6));
   items.add(new MetricItem(date.plusMinutes(20), 1, 3, 10, 6, 2, 8, 3, 8));
 }
Exemplo n.º 17
0
  private void addTimeSlot(
      List<TimeSlot> timeSlots,
      LocalDateTime time,
      CalendarConfig config,
      BigDecimal pricePerMinDuration) {
    TimeSlot timeSlot = new TimeSlot();
    timeSlot.setDate(time.toLocalDate());
    timeSlot.setStartTime(time.toLocalTime());
    timeSlot.setEndTime(time.toLocalTime().plusMinutes(config.getMinDuration()));
    timeSlot.setConfig(config);
    timeSlot.setPricePerMinDuration(pricePerMinDuration);

    // only add timeSlot if timeSlots does not already contain an entry that overlaps
    if (!overlaps(timeSlot, timeSlots)) {
      timeSlots.add(timeSlot);
    }
  }
  public void insertSessions(String eventId, LocalDate date) {
    LocalDateTime dateTime = date.toLocalDateTime(LocalTime.MIDNIGHT);

    dateTime = dateTime.plusHours(9);

    Session session1 = new Session();
    session1.setEventId(eventId);
    session1.setTitle("Session 1");
    session1.setTimeslot(new Interval(dateTime.toDateTime(), Minutes.minutes(60)));
    session1.setRoom(room1);
    sessionDao.saveSession(session1);

    dateTime = dateTime.plusHours(1);

    Session session2 = new Session();
    session2.setEventId(eventId);
    session2.setTitle("Session 2");
    session2.setTimeslot(new Interval(dateTime.toDateTime(), Minutes.minutes(60)));
    session2.setRoom(room2);
    sessionDao.saveSession(session2);

    dateTime = dateTime.plusHours(1);

    Session session3 = new Session();
    session3.setEventId(eventId);
    session3.setTitle("Session 3");
    session3.setTimeslot(new Interval(dateTime.toDateTime(), Minutes.minutes(60)));
    session3.setRoom(room3);
    sessionDao.saveSession(session3);
  }
Exemplo n.º 19
0
 @Override
 public Calendar marshal(LocalDateTime localTime) throws Exception {
   if (localTime == null) {
     return null;
   }
   Calendar calendar = Calendar.getInstance();
   calendar.setTimeInMillis(localTime.getMillisOfDay());
   return calendar;
 }
  public List<GameEntity> findByBallTypeAndGameStatus(String ballType, Long gameStatus) {
    Criteria criteria = getSession().createCriteria(GameEntity.class);
    criteria = criteria.setFetchMode("odds", FetchMode.SELECT);
    Criterion firstCri = Restrictions.eq("ballType", ballType);
    Criterion secondCri = Restrictions.eq("gameStatus", gameStatus);
    Criterion thirdCri = Restrictions.gt("gameTime", LocalDateTime.now());
    Criterion extraCri = Restrictions.le("gameTime", LocalDateTime.now());
    if (gameStatus != null) {
      if (gameStatus == 1L) criteria = criteria.add(firstCri).add(secondCri).add(thirdCri);
      else criteria = criteria.add(firstCri).add(secondCri);
    } else {
      gameStatus = 1L;
      secondCri = Restrictions.eq("gameStatus", gameStatus);
      criteria = criteria.add(firstCri).add(secondCri).add(extraCri);
    }

    return criteria.list();
  }
Exemplo n.º 21
0
  @Before
  public void setup() throws Exception {
    testDateTimeProvider.setTime(LocalDateTime.parse("2001-02-04T17:00:00"));
    databaseHelper.addObjects(OWNER_MNT, TEST_PERSON);

    ReflectionTestUtils.setField(
        restClient, "restApiUrl", String.format("http://localhost:%d/whois", getPort()));
    ReflectionTestUtils.setField(restClient, "sourceName", "TEST");
  }
Exemplo n.º 22
0
 public String getBirthdayAsFormattedString() {
   DateTimeFormatter formatter =
       DateTimeFormat.forPattern(AppConstants.DateFormat.DF_yyyyMMdd_minus);
   if (birthday != null) {
     return birthday.toString(formatter);
   } else {
     return "0000-00-00";
   }
 }
Exemplo n.º 23
0
    @Override
    public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;

      DayToSelect that = (DayToSelect) o;

      return date.equals(that.date);
    }
  public Content postEvent(
      String headline,
      double latitude,
      double longitude,
      String body,
      String link,
      MediaFile image,
      VideoAttachment video,
      String noticeboard,
      LocalDateTime startDate,
      LocalDateTime endDate,
      Reoccurence reoccurence,
      LocalDateTime reoccursTo)
      throws N0ticeException {
    final OAuthRequest request = createOauthRequest(Verb.POST, apiUrl + "/event/new");

    final MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
    addEntityPartParameter(entity, "headline", headline);
    addEntityPartParameter(entity, "noticeboard", noticeboard);
    addEntityPartParameter(entity, "latitude", Double.toString(latitude));
    addEntityPartParameter(entity, "longitude", Double.toString(longitude));
    populateUpdateFields(body, link, image, video, entity);

    addEntityPartParameter(entity, "startDate", startDate.toString(LOCAL_DATE_TIME_FORMAT));
    addEntityPartParameter(entity, "endDate", endDate.toString(LOCAL_DATE_TIME_FORMAT));
    if (reoccurence != null && reoccursTo != null) {
      addEntityPartParameter(entity, "reoccurs", reoccurence.toString());
      addEntityPartParameter(entity, "reoccursTo", reoccursTo.toString(LOCAL_DATE_TIME_FORMAT));
    }

    request.addHeader("Content-Type", entity.getContentType().getValue());
    addMultipartEntity(request, entity);
    oauthSignRequest(request);

    Response response = request.send();

    final String responseBody = response.getBody();
    if (response.getCode() == 200) {
      return searchParser.parseReport(responseBody);
    }

    handleExceptions(response);
    throw new N0ticeException(response.getBody());
  }
Exemplo n.º 25
0
 @POST
 @Consumes(MediaType.APPLICATION_JSON)
 @Produces(MediaType.APPLICATION_JSON)
 @Timed
 @UnitOfWork
 public Orchestration create(Orchestration entity) {
   entity.setState(OrchestrationState.Initialized);
   LocalDateTime now = LocalDateTime.now();
   entity.setCreated(now);
   entity.setLastModified(now);
   return dao.save(entity);
 }
Exemplo n.º 26
0
 public void setEnd(LocalDateTime end) {
   this.end = end;
   if (start != null && end != null) {
     this.duration = end.toDate().getTime() - start.toDate().getTime();
   }
   if (updates != null) {
     updates.isEndChanged = true;
     if (parent != null) {
       parent.propagateActivityInstanceChange();
     }
   }
 }
Exemplo n.º 27
0
  // should be private, but public because of unit test visibility
  public void detachWeekdaysFromWeekends(List<ParkingEvent> parkingEvents) {

    totalHours = 0; // for weekday hours

    weekends = new HashSet<String>(); // storing weekend days

    // iterating over events
    for (ParkingEvent parkingEvent : parkingEvents) {

      LocalDateTime startDateTime = new LocalDateTime(parkingEvent.getStartTime());
      LocalDateTime endDateTime = new LocalDateTime(parkingEvent.getEndTime());

      // iterating over event hours
      for (LocalDateTime date = startDateTime;
          date.isBefore(endDateTime);
          date = date.plusHours(1)) {
        if (date.getDayOfWeek() == DateTimeConstants.SATURDAY
            || date.getDayOfWeek() == DateTimeConstants.SUNDAY) {
          weekends.add(date.toLocalDate().toString());
        } else {
          totalHours++;
        }
      }
    }
  }
Exemplo n.º 28
0
  @Override
  public void setValue(Object value) {

    LocalDateTime localDateTime;

    if (value instanceof Date) {

      Date date = (Date) value;
      localDateTime = LocalDateTime.fromDateFields(date);
    } else if (value instanceof LocalDateTime) {
      localDateTime = (LocalDateTime) value;
    } else {
      return;
    }

    // hour
    SingleSelectionSpinner<HourToSelect> hourSelector =
        (SingleSelectionSpinner<HourToSelect>) findViewById(R.id.timePicker1);

    for (int i = 0; i < this.hourToSelectList.size(); i++) {
      HourToSelect hourToSelect = this.hourToSelectList.get(i);
      if (hourToSelect.getHour() == localDateTime.getHourOfDay()) {
        hourSelector.setSelection(i);
        break;
      }
    }

    // day
    localDateTime = localDateTime.withMillisOfDay(0);
    SingleSelectionSpinner<DayToSelect> daySelector =
        (SingleSelectionSpinner<DayToSelect>) findViewById(R.id.datePicker1);

    for (int i = 0; i < this.dayToSelectList.size(); i++) {
      DayToSelect dayToSelect = this.dayToSelectList.get(i);
      if (dayToSelect.getDate().equals(localDateTime)) {
        daySelector.setSelection(i);
        break;
      }
    }
  }
Exemplo n.º 29
0
  private void initialization() {

    Date value = getValue();

    dayToSelectList.clear();
    hourToSelectList.clear();

    SingleSelectionSpinner<DayToSelect> daySelector =
        (SingleSelectionSpinner<DayToSelect>) findViewById(R.id.datePicker1);
    SingleSelectionSpinner<HourToSelect> hourSelector =
        (SingleSelectionSpinner<HourToSelect>) findViewById(R.id.timePicker1);

    // build date
    LocalDateTime now = startDate;
    now = now.withMillisOfDay(0);
    now = now.withHourOfDay(0);

    for (int i = 0; i < maxDay; i++) {
      dayToSelectList.add(new DayToSelect(now, now.getDayOfMonth() + "/" + now.getMonthOfYear()));
      now = now.plusDays(1);
    }

    daySelector.setItems(dayToSelectList);

    // build date
    for (int i = 0; i <= 24; i++) {
      hourToSelectList.add(new HourToSelect(i, i + ":00"));
    }

    hourSelector.setItems(hourToSelectList);

    if (value != null) {
      setValue(value);
    }
  }
Exemplo n.º 30
0
  /**
   * Validate input. Only description can be empty. Start date can not be after end date. Method
   * shows proper error message.
   *
   * @return true if input is proper, false otherwise
   */
  public boolean ValidateForm() {
    String errorMsg = "";
    StringValidator validator = new StringValidator();
    errorMsg += validator.isEmpty("Title", tbTitle.getText().toString());
    errorMsg += validator.isEmpty("Place", tbPlace.getText().toString());
    errorMsg += validator.isEmpty("Start date", tbStartDate.getText().toString());
    errorMsg += validator.isEmpty("End date", tbEndDate.getText().toString());
    errorMsg += validator.isEmpty("Start time", tbStartTime.getText().toString());
    errorMsg += validator.isEmpty("End time", tbEndTime.getText().toString());

    LocalDateTime startFinalDate = startDate.toLocalDateTime(startTime);
    LocalDateTime endFinalDate = endDate.toLocalDateTime(endTime);

    if (startFinalDate.isAfter(endFinalDate))
      errorMsg += "End date can not be before start date!\n";

    if (errorMsg.length() == 0) return true;
    else {
      ModalService.ShowErrorModal(errorMsg, AddEventActivity.this);
      return false;
    }
  }