Package de.danet.an.util

Examples of de.danet.an.util.Duration


      try {
    Object res = process.evalScript (getCondition ());
    if (res instanceof Date) {
        cond = (Date)res;
    } else if (res instanceof Number) {
        cond = new Duration ();
        ((Duration)cond).setSeconds
      (((Number)res).floatValue ());
    } else {
        throw new ParseException
      ("Evaluating duration \"" + getCondition()
       + "\" yields neither number nor date.", 0);
    }
      } catch (ScriptException e) {
    throw new ParseException
        ("Problem evaluating duration value \""
         + getCondition() + "\": " + e.getMessage(), 0);
      } finally {
    cx.exit();
      }
  }
  Date end = null;
  if (cond instanceof Date) {
      end = (Date)cond;
  } else {
      Duration dur = (Duration)cond;
      end = dur.addTo (baseTime);
  }
  return end;
    }
View Full Code Here


    /**
     * Parse a duration
     */
    public void parseDuration() throws Exception {
  String duration = "P123Y456M789D";
  Duration d = XMLUtil.parseXsdDuration (duration);
  assertTrue (d.getYears() == 123);
  assertTrue (d.getMonths() == 456);
  assertTrue (d.getDays() == 789);
  assertTrue (d.getHours() == 0);
  assertTrue (d.getMinutes() == 0);
  assertTrue (d.getSeconds() == 0);

  duration = "P123Y456M789DT987H654M321.123S";
  d = XMLUtil.parseXsdDuration (duration);
  assertTrue (d.getYears() == 123);
  assertTrue (d.getMonths() == 456);
  assertTrue (d.getDays() == 789);
  assertTrue (d.getHours() == 987);
  assertTrue (d.getMinutes() == 654);
  assertTrue (d.getSeconds() == (float)321.123);

  duration = "PT1M0.1S";
  d = XMLUtil.parseXsdDuration (duration);
  assertTrue (d.getYears() == 0);
  assertTrue (d.getMonths() == 0);
  assertTrue (d.getDays() == 0);
  assertTrue (d.getHours() == 0);
  assertTrue (d.getMinutes() == 1);
  assertTrue (d.getSeconds() == (float)0.1);
    }
View Full Code Here

TOP

Related Classes of de.danet.an.util.Duration

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.