Examples of MyDate


Examples of de.jetwick.util.MyDate

    public void testAddSomeMore() throws InterruptedException {
        tester.getSearch().setRemoveOlderThanDays(1);

        BlockingQueue<JTweet> queue = tweetConsumer.register("tweet-producer", Integer.MAX_VALUE, 3);
        JTweet tw = createTweetWithUrl(4L, "http://test.de text", "userB", "http://test.de");
        tw.setCreatedAt(new MyDate().minusDays(2).toDate());
        JTweet tw2 = createTweetWithUrl(5L, "RT @userB: http://test.de text", "timetabling", "http://test.de");
        tw2.setCreatedAt(new Date());
        JTweet tw3 = createTweet(6L, "Bla bli", "userB");
        tw3.setCreatedAt(new Date());
        queue.addAll(Arrays.asList(tw, tw2, tw3));
View Full Code Here

Examples of de.jetwick.util.MyDate

        if (isDateFacets()) {
            // too much work to convert the generic case with all the date math
            // so cheat for our case:
            String name = ElasticTweetSearch.DATE_FACET;
            RangeFacetBuilder rfb = FacetBuilders.rangeFacet(name).field(ElasticTweetSearch.DATE);
            MyDate date = new MyDate();

            // latest
            rfb.addUnboundedTo(Helper.toLocalDateTime(date.clone().minusHours(8).castToHour().toDate()));
            // first day           
            rfb.addUnboundedTo(Helper.toLocalDateTime(date.castToDay().toDate()));

            for (int i = 0; i < 7; i++) {
                // 'from' must be smaller than 'to'!
                Date oldDate = date.toDate();
                rfb.addRange(Helper.toLocalDateTime(date.minusDays(1).toDate()),
                        Helper.toLocalDateTime(oldDate));
            }

            // oldest
            rfb.addUnboundedFrom(Helper.toLocalDateTime(date.toDate()));
            srb.addFacet(rfb);
        }

        return srb;
    }
View Full Code Here

Examples of de.jetwick.util.MyDate

//                lang("js").param("mynow", time);
    }

    @Override
    public JetwickQuery addLatestDateFilter(int hours) {
        return addLatestDateFilter(new MyDate().minusHours(hours).castToHour());
    }
View Full Code Here

Examples of de.jetwick.util.MyDate

            try {
                // add some noise when waiting to avoid being identified or filtered out as bot ;-)
                long tmp = (long) (interval + interval * rand.nextDouble() * 0.3);

                logger.info("wait " + (tmp / 60f / 1000f) + " minutes => next tweet on: " + new MyDate().plusMillis(tmp));
                Thread.sleep(tmp);
            } catch (InterruptedException ex) {
                logger.warn("Interrupted " + ex.getMessage());
                break;
            }
View Full Code Here

Examples of de.jetwick.util.MyDate

        }
    }

    public Collection<JTweet> search() {
        JetwickQuery query = new TweetQuery(). // should be not too old
                addFilterQuery(DATE, "[" + new MyDate().minusDays(1).toLocalString() + " TO *]").
                // should be high quality
                addFilterQuery(QUALITY, "[90 TO *]").
                // should be the first tweet with this content
                addFilterQuery(DUP_COUNT, 0).
                // only tweets which were already tweeted minRT-times
View Full Code Here

Examples of de.jetwick.util.MyDate

        qb.setQuery(QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), FilterBuilders.termFilter(TERM, term)));
        client.deleteByQuery(qb.request());
    }

    public void deleteOlderThan(int hours) {
        RangeQueryBuilder sqb = QueryBuilders.rangeQuery(LAST_REQ).lt(new MyDate().minusHours(hours).toDate());
        DeleteByQueryRequestBuilder dbq = client.prepareDeleteByQuery(getIndexName()).setQuery(sqb);
        client.deleteByQuery(dbq.request());
    }
View Full Code Here

Examples of model.MyDate

   */
  @SuppressWarnings("unused")
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int year, month, day;
    MyDate next = new MyDate();
    MyDate previous = new MyDate();
    try {
      year = in.nextInt();
      month = in.nextInt();
      day = in.nextInt();
    } catch (Exception e) {
      System.out.println("请输入正确的数字");
      return;
    }
    if (!isCorrect(year, month, day)) {
      System.out.println("请输入正确的日期");
      return;
    }

    if (!isFirst(year, month, day) && !isLast(year, month, day)) {
      next.setMonth(month);
      next.setYear(year);
      next.setDay(day + 1);
      previous.setYear(year);
      previous.setMonth(month);
      previous.setDay(day - 1);

    } else if (isFirst(year, month, day)) {
      if (!isFirstYear(year, month, day)) {
        previous.setYear(year);
        previous.setMonth(month - 1);
        if (isLeapYear(year)) {
          previous.setDay(days29[month - 2]);
        } else {
          previous.setDay(days28[month - 2]);
        }
      } else {
        previous.setYear(year - 1);
        previous.setMonth(12);
        previous.setDay(31);
      }
      next.setMonth(month);
      next.setYear(year);
      next.setDay(day + 1);
    } else if (isLast(year, month, day)) {
      if (!isLastYear(year, month, day)) {
        next.setMonth(month + 1);
        next.setYear(year);
        next.setDay(1);

      } else {
        next.setMonth(1);
        next.setYear(year + 1);
        next.setDay(1);
      }
      previous.setYear(year - 1);
      previous.setMonth(month);
      previous.setDay(day - 1);
    }
    System.out.println("下一天是" + next);
    System.out.println("前一天是" + previous);
    return;
  }
View Full Code Here

Examples of model.MyDate

  }

  @Test
  public void testGetNext() {
    // System.out.println(getDate(1987, 88));
    System.out.println(getNext(new MyDate(1989, 2, 1)));
    System.out.println(getNext(new MyDate(1998, 3, 5)));
    System.out.println(getNext(new MyDate(2012, 6, 7)));
  }
View Full Code Here

Examples of model.MyDate

  }

  @Test
  public void testGetPrevious() {
    // System.out.println(getDate(1987, 88));
    System.out.println(getPrevious(new MyDate(1989, 2, 1)));
    System.out.println(getPrevious(new MyDate(1998, 3, 5)));
    System.out.println(getPrevious(new MyDate(2012, 6, 7)));
  }
View Full Code Here

Examples of model.MyDate

    all += day;
    return all;
  }

  public MyDate getDate(int year, int days) {
    MyDate myDate = new MyDate();
    int m = 0;
    if ((days > 365 && !isLeapYear(year))
        || (days > 366 && isLeapYear(year))) {
      myDate.setYear(year++);
      myDate.setMonth(1);
      myDate.setDay(1);
      return myDate;
    }
    do {
      days = days - this.days[m++];
      if (m == 2 && !isLeapYear(year)) {
        days++;
      }
    } while (days > 0);
    myDate.setDay(this.days[--m] + days);
    myDate.setMonth(m);
    myDate.setYear(year);
    return myDate;

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.