Package org.goda.time

Examples of org.goda.time.MutableInterval


     */
    public void testParse_String() {
        System.out.println("parse");
        Options o = new Options();
        o.setDebug(true);
        MutableInterval expResult = null;
        MutableInterval result = Chronic.parse("this tuesday 5:00", o);
        System.out.println(result);
        result = Chronic.parse("1979-05-27", o);
        System.out.println(result);

        result = Chronic.parse("Aug 23, 2010", o);
        System.out.println(result);

        result = Chronic.parse("1st monday in sept", o);
        System.out.println(result);

        result = Chronic.parse("september 4th", o);
        System.out.println(result);

        result = Chronic.parse("1st of september", o);
        System.out.println(result);

        result = Chronic.parse("three hundred twenty-one and a half days ago", o);
        System.out.println(result);

        o = new Options();
        o.setDebug(true);
       
         System.out.println("1.25 hr ago");
        result = Chronic.parse("1.25 hr ago", o);
        System.out.println(new Date(result.getStartMillis()));
       
       
        System.out.println("17:50");
        result = Chronic.parse("17:50", o);
        System.out.println(new Date(result.getStartMillis()));
       
        System.out.println("3 am");
        result = Chronic.parse("3 am", o);
        System.out.println(result.getStart());
       
      
       
        System.out.println("3a");
        result = Chronic.parse("3a", o);
        System.out.println(new Date(result.getStartMillis()));
       
        System.out.println("10021974");
        result = Chronic.parse("10021974", o);
        System.out.println(result.getStart());
       
       
        System.out.println("023");
        result = Chronic.parse("023", o);
        System.out.println(result.getStart());
       
        System.out.println("1630");
        result = Chronic.parse("1630", o);
        System.out.println(result.getStart());
       
        System.out.println("16:50 10/2/1974");
        result = Chronic.parse("16:50 10/2/1974 ", o);
        System.out.println(result.getStart());
       
       
        System.out.println("16:50 10021974");
        result = Chronic.parse("16:50 10021974 ", o);
        System.out.println(result.getStart());
       
       
       
        System.out.println("10:00am");
        result = Chronic.parse("10:00am");
        System.out.println(result.getStart());
       
       
        System.out.println("10:00a 9/23/2011");
        result = Chronic.parse("10:00a 9/23/2011");
        System.out.println(result.getStart());
   
        System.out.println("sept 11 2001");
        result = Chronic.parse("sept 11 2001");
        System.out.println(result.getStart());
       
       
       
       
        System.out.println("10:00am sept 11 2001");
        result = Chronic.parse("10:00am sept 11 2001");
        System.out.println(result.getStart());
   
    }
View Full Code Here


     */
    public void xtestParse_String_Options() {
        System.out.println("parse");
        String text = "";
        Options options = null;
        MutableInterval expResult = null;
        MutableInterval result = Chronic.parse(text, options);
        assertEquals(expResult, result);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }
View Full Code Here

        if (options.isDebug()) {
            System.out.println("Chronic.parse: " + tokens);
        }

        MutableInterval MutableInterval = Handler.tokensToMutableInterval(tokens, options);

        // guess a time within a MutableInterval if required
        if (options.isGuess()) {
            MutableInterval = guess(MutableInterval);
        }
View Full Code Here

            guessValue = mutableInterval.getStart().getMillis() + (Time.getWidth(mutableInterval) / 2);
        } else {
            guessValue = mutableInterval.getStart().getMillis();
        }

        MutableInterval guess = new MutableInterval(guessValue, guessValue);

        return guess;
    }
View Full Code Here

        if (time.isAfterNow() && (options.getContext() == PointerType.PAST)) {
            time.addDays(-1);
        }

        MutableInterval result = new MutableInterval(time, time);
        result.setStart(time);
        result.setEnd(time);

        return result;
    }
View Full Code Here

      int increment = (tick.isAmbiguous()) ? halfDay : fullDay;
      int direction = (pointer == Pointer.PointerType.FUTURE) ? 1 : -1;
      _currentTime = _currentTime.plusSeconds( direction * increment);
    }

    return new MutableInterval(_currentTime, _currentTime.plusSeconds(getWidth()));
  }
View Full Code Here

      }
    }
    else {
      _currentDayStart = _currentDayStart.plusDays( direction * 7);
    }
    return new MutableInterval(_currentDayStart, _currentDayStart.plusMonths(1));
  }
View Full Code Here

    return new MutableInterval(_currentWeekStart, Time.cloneAndAdd(_currentWeekStart, Time.SECOND, RepeaterWeekend.WEEKEND_SECONDS));
  }

  @Override
  protected MutableInterval _thisMutableInterval(PointerType pointer) {
    MutableInterval thisMutableInterval;
    if (pointer == Pointer.PointerType.FUTURE || pointer == Pointer.PointerType.NONE) {
      RepeaterDayName saturdayRepeater = new RepeaterDayName(RepeaterDayName.DayName.SATURDAY);
      saturdayRepeater.setStart(new DateTime(getNow()));
      MutableInterval thisSaturdayMutableInterval = saturdayRepeater.nextMutableInterval(Pointer.PointerType.FUTURE);
      thisMutableInterval = new MutableInterval(thisSaturdayMutableInterval.getStart(), Time.cloneAndAdd(thisSaturdayMutableInterval.getStart(), Time.SECOND, RepeaterWeekend.WEEKEND_SECONDS));
    }
    else if (pointer == Pointer.PointerType.PAST) {
      RepeaterDayName saturdayRepeater = new RepeaterDayName(RepeaterDayName.DayName.SATURDAY);
      saturdayRepeater.setStart( new DateTime( getNow()));
      MutableInterval lastSaturdayMutableInterval = saturdayRepeater.nextMutableInterval(Pointer.PointerType.PAST);
      thisMutableInterval = new MutableInterval(lastSaturdayMutableInterval.getStart(), Time.cloneAndAdd(lastSaturdayMutableInterval.getStart(), Time.SECOND, RepeaterWeekend.WEEKEND_SECONDS));
    }
    else {
      throw new IllegalArgumentException("Unable to handle pointer " + pointer + ".");
    }
    return thisMutableInterval;
View Full Code Here

  public MutableInterval getOffset(MutableInterval span, double amount, PointerType pointer) {
    int direction = (pointer == Pointer.PointerType.FUTURE) ? 1 : -1;
    RepeaterWeekend weekend = new RepeaterWeekend();
    weekend.setStart(span.getStart());
    DateTime start = Time.cloneAndAdd(weekend.nextMutableInterval(pointer).getStart(), Time.SECOND, (int) ((amount - 1) * direction * RepeaterWeek.WEEK_SECONDS));
    return new MutableInterval(start, Time.cloneAndAdd(start, Time.SECOND, Time.getWidth(span)));
  }
View Full Code Here

    }
    else {
      _currentMonthStart = Time.cloneAndAdd(_currentMonthStart, Time.MONTH, direction);
    }

    return new MutableInterval(_currentMonthStart, _currentMonthStart.plusMonths(1));
  }
View Full Code Here

TOP

Related Classes of org.goda.time.MutableInterval

Copyright © 2018 www.massapicom. 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.