Package org.apache.solr.util

Examples of org.apache.solr.util.DateMathParser.parseMath()


        Date low = start;
        while (low.before(end)) {
          dmp.setNow(low);
          String label = ft.toExternal(low);
         
          Date high = dmp.parseMath(gap);
          if (end.before(high)) {
            if (params.getFieldBool(f,FacetParams.FACET_DATE_HARD_END,false)) {
              high = end;
            } else {
              end = high;
View Full Code Here


      return val.substring(0,len-1);
    } else if (val.startsWith("NOW")) {
      /* :TODO: let Locale/TimeZone come from init args for rounding only */
      DateMathParser p = new DateMathParser(UTC, Locale.US);
      try {
        return toInternal(p.parseMath(val.substring(3)));
      } catch (ParseException e) {
        throw new SolrException(400,"Invalid Date Math String:'" +val+'\'',e);
      }
    }
    throw new SolrException(400,"Invalid Date String:'" +val+'\'');
View Full Code Here

        Date low = start;
        while (low.before(end)) {
          dmp.setNow(low);
          final String lowI = ft.toInternal(low);
          final String label = ft.indexedToReadable(lowI);
          Date high = dmp.parseMath(gap);
          if (end.before(high)) {
            if (params.getFieldBool(f,FacetParams.FACET_DATE_HARD_END,false)) {
              high = end;
            } else {
              end = high;
View Full Code Here

  public void testParseStatelessness() throws Exception {

    DateMathParser p = new DateMathParser(UTC, Locale.US);
    p.setNow(parser.parse("2001-07-04T12:08:56.235"));

    String e = fmt.format(p.parseMath(""));
   
    Date trash = p.parseMath("+7YEARS");
    trash = p.parseMath("/MONTH");
    trash = p.parseMath("-5DAYS+20MINUTES");
    Thread.currentThread().sleep(5);
View Full Code Here

    DateMathParser p = new DateMathParser(UTC, Locale.US);
    p.setNow(parser.parse("2001-07-04T12:08:56.235"));

    String e = fmt.format(p.parseMath(""));
   
    Date trash = p.parseMath("+7YEARS");
    trash = p.parseMath("/MONTH");
    trash = p.parseMath("-5DAYS+20MINUTES");
    Thread.currentThread().sleep(5);
   
    String a = fmt.format(p.parseMath(""));
View Full Code Here

    p.setNow(parser.parse("2001-07-04T12:08:56.235"));

    String e = fmt.format(p.parseMath(""));
   
    Date trash = p.parseMath("+7YEARS");
    trash = p.parseMath("/MONTH");
    trash = p.parseMath("-5DAYS+20MINUTES");
    Thread.currentThread().sleep(5);
   
    String a = fmt.format(p.parseMath(""));
    assertEquals("State of DateMathParser changed", e, a);
View Full Code Here

    String e = fmt.format(p.parseMath(""));
   
    Date trash = p.parseMath("+7YEARS");
    trash = p.parseMath("/MONTH");
    trash = p.parseMath("-5DAYS+20MINUTES");
    Thread.currentThread().sleep(5);
   
    String a = fmt.format(p.parseMath(""));
    assertEquals("State of DateMathParser changed", e, a);
  }
View Full Code Here

    Date trash = p.parseMath("+7YEARS");
    trash = p.parseMath("/MONTH");
    trash = p.parseMath("-5DAYS+20MINUTES");
    Thread.currentThread().sleep(5);
   
    String a = fmt.format(p.parseMath(""));
    assertEquals("State of DateMathParser changed", e, a);
  }
   
  public void testParseMath() throws Exception {
View Full Code Here

    badCommands.put("/4", 1);
    badCommands.put("?SECONDS", 0);

    for (String command : badCommands.keySet()) {
      try {
        Date out = p.parseMath(command);
        fail("Didn't generate ParseException for: " + command);
      } catch (ParseException e) {
        assertEquals("Wrong pos for: " + command + " => " + e.getMessage(),
                     badCommands.get(command).intValue(), e.getErrorOffset());
View Full Code Here

      return val.substring(0,len-1);
    } else if (val.startsWith("NOW")) {
      /* :TODO: let Locale/TimeZone come from init args for rounding only */
      DateMathParser p = new DateMathParser(UTC, Locale.US);
      try {
        return toInternal(p.parseMath(val.substring(3)));
      } catch (ParseException e) {
        throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Invalid Date Math String:'" +val+'\'',e);
      }
    }
    throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Invalid Date String:'" +val+'\'');
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.