Examples of Duration


Examples of javax.time.Duration

     * @throws ArithmeticException if the calculation exceeds the capacity of {@code Instant}
     * @throws CalendricalException if the calculation exceeds the capacity of {@code ZonedDateTime}
     */
    public ZonedDateTime plusDuration(PeriodProvider periodProvider) {
        PeriodFields period = PeriodFields.from(periodProvider);
        Duration duration = period.toDuration();
        return duration.isZero() ? this : fromInstant(toInstant().plus(duration), zone);
    }
View Full Code Here

Examples of javax.xml.datatype.Duration

        static final DurationAdd INSTANCE = new DurationAdd();

        public DurationValue eval(DynamicContext dynEnv, Item v1, Item v2) throws XQueryException {
            DurationValue d1 = (DurationValue) v1;
            DurationValue d2 = (DurationValue) v2;
            Duration dv1 = d1.getValue();
            Duration res = dv1.add(d2.getValue());
            DurationType dt1 = d1.getDurationType();
            DurationType dt2 = d2.getDurationType();
            if(dt1 == dt2) {
                return new DurationValue(res, dt1);
            } else {
View Full Code Here

Examples of javax.xml.datatype.Duration

    }

    public void testDuration() throws Exception {
        javax.xml.datatype.DatatypeFactory datatypeFactory = javax.xml.datatype.DatatypeFactory.newInstance();

        Duration x = datatypeFactory.newDuration("P1Y35DT60M60.500S");
        Duration yOrig = datatypeFactory.newDuration("-P2MT24H60S");

        Holder<Duration> y = new Holder<Duration>(yOrig);
        Holder<Duration> z = new Holder<Duration>();

        Duration ret = client.testDuration(x, y, z);           
        if (!perfTestOnly) {
            assertTrue("testDuration(): Incorrect value for inout param", x.equals(y.value));
            assertTrue("testDuration(): Incorrect value for out param", yOrig.equals(z.value));
            assertTrue("testDuration(): Incorrect return value", x.equals(ret));
        }
View Full Code Here

Examples of javax.xml.datatype.Duration

            // A lot of testing to keep it as derived types.
            boolean isDTDur = dtXSDdayTimeDuration.equals(nv1.getDatatypeURI()) &&
                              dtXSDdayTimeDuration.equals(nv2.getDatatypeURI()) ;
            boolean isYMDur = dtXSDyearMonthDuration.equals(nv1.getDatatypeURI()) &&
                              dtXSDyearMonthDuration.equals(nv2.getDatatypeURI()) ;
            Duration d3 = nv1.getDuration().add(nv2.getDuration()) ;
            String lex = d3.toString() ;
            Node n ;
            if ( isDTDur )
                n = NodeFactory.createLiteralNode(lex, null, dtXSDdayTimeDuration) ;
            else if ( isYMDur )
                n = NodeFactory.createLiteralNode(lex, null, dtXSDyearMonthDuration) ;
View Full Code Here

Examples of javax.xml.datatype.Duration

         // A lot of testing to keep it as derived types.
            boolean isDTDur = dtXSDdayTimeDuration.equals(nv1.getDatatypeURI()) &&
                              dtXSDdayTimeDuration.equals(nv2.getDatatypeURI()) ;
            boolean isYMDur = dtXSDyearMonthDuration.equals(nv1.getDatatypeURI()) &&
                              dtXSDyearMonthDuration.equals(nv2.getDatatypeURI()) ;
            Duration d3 = nv1.getDuration().subtract(nv2.getDuration()) ;
            String lex = d3.toString() ;
            Node n ;
            if ( isDTDur )
                n = NodeFactory.createLiteralNode(lex, null, dtXSDdayTimeDuration) ;
            else if ( isYMDur )
                n = NodeFactory.createLiteralNode(lex, null, dtXSDyearMonthDuration) ;
View Full Code Here

Examples of javax.xml.datatype.Duration

            return XSDFuncOp.numMultiply(nv1, nv2) ;

        if ( vs1.equals(VSPACE_DURATION) && vs2.equals(VSPACE_NUM) )
        {
            // ONLY defined for dayTime.
            Duration dur = nv1.getDuration() ;
            boolean valid = XSDFuncOp.isDayTime(dur) ;
            if ( ! valid )
                throw new ExprEvalTypeException("Operator '*': only dayTime duration.  Got: "+nv1) ;
            BigDecimal dec = nv2.getDecimal() ;
            Duration r = dur.multiply(dec) ;
            Node n = NodeFactory.createLiteralNode(r.toString(), null, dtXSDdayTimeDuration) ;
            return NodeValue.makeNodeDuration(r, n) ;
        }
        throw new ExprEvalTypeException("Operator '*' : Undefined multiply: "+nv1+" and "+nv2) ;
    }
View Full Code Here

Examples of mf.javax.xml.datatype.Duration

        XMLGregorianCalendar result = (XMLGregorianCalendar) cal.clone();

        // normalizing to UTC time negates the timezone offset before
        // addition.
        minutes = -minutes;
        Duration d = new DurationImpl(minutes >= 0, // isPositive
                0, //years
                0, //months
                0, //days
                0, //hours
                minutes < 0 ? -minutes : minutes, // absolute
View Full Code Here

Examples of name.pehl.karaka.shared.model.Duration

        DateMidnight now = now(settings.get().getTimeZone());
        int year = now.year().get();
        int month = now.monthOfYear().get();
        int week = now.weekOfWeekyear().get();
        int day = now.dayOfMonth().get();
        Duration currentMonth = minutes(repository.findByYearMonth(year, month));
        Duration currentWeek = minutes(repository.findByYearWeek(year, week));
        Duration today = minutes(repository.findByYearMonthDay(year, month, day));
        Durations durations = new Durations(currentMonth, currentWeek, today);

        String url = uriInfo.getAbsolutePath().toASCIIString();
        LinkHeader linkHeader = new LinkHeader().addLink(null, SELF, url, null);
        return Response.ok(durations).header("Link", linkHeader.toString()).build();
View Full Code Here

Examples of net.aufdemrand.denizen.objects.Duration

        // Initialize necessary fields
        Map<String, String> context = null;
        Boolean instant = false;
        dScript script = null;
        Duration delay = null;
        String queue = scriptEntry.getResidingQueue().id;

        // Iterate through Arguments to extract needed information
        for (String arg : scriptEntry.getArguments()) {

            // Specify scriptContainer to use
            if (aH.matchesScript(arg)) {
                script = aH.getScriptFrom(arg);

            }   // Delay the start of the queue
            else if (aH.matchesValueArg("DELAY", arg, aH.ArgumentType.Duration)) {
                delay = aH.getDurationFrom(arg);

            }   // Use a specific queue
            else if (aH.matchesQueue(arg)) {
                queue = aH.getStringFrom(arg);

            }   // TODO: Remove this argument for version 1.0
            else if (aH.matchesValueArg("SPEED", arg, aH.ArgumentType.Duration)) {
                dB.log("SPEED argument has been removed from RUNTASK! Instead, specify " +
                        "a speed on the task script itself, or use the 'QUEUE SET_SPEED:#' command " +
                        "inside the task script. This warning will be removed in version 1.0 " +
                        "and this command will be deprecated.");

            }   // Gets a new, randomly named queue
            else if (aH.matchesArg("QUEUE", arg)) {
                queue = ScriptQueue.getNextId("RUNTASK");
                instant = false;

            }   // Run the script instantly.
            else if (aH.matchesArg("INSTANT, INSTANTLY", arg)) {
                queue = ScriptQueue.getNextId("RUNTASK");
                instant = true;

            }   // Build context map if specified
            else if (aH.matchesContext(arg)) {
                context = aH.getContextFrom(arg);

            }   // Specify a script name without the 'script:' prefix
            else if (ScriptRegistry.containsScript(aH.getStringFrom(arg))) {
                script = aH.getScriptFrom(arg);
                if (!script.getType().equalsIgnoreCase("TASK"))
                    script = null;

            } else throw new InvalidArgumentsException("Unknown argument '" + arg + "'!");
        }

        // Must specify at least a valid script to run...
        if (script == null)
            throw new InvalidArgumentsException("Must define a SCRIPT to be run.");
        // If not queue, and delayed, throw an exception... this cannot happen.
        if (queue.equals(scriptEntry.getResidingQueue().id) && delay != null)
            throw new InvalidArgumentsException("Cannot delay an INJECTED task script! Use 'QUEUE'.");

        // Put important objects inside the scriptEntry to be sent to execute()
        scriptEntry.addObject("instant", instant)
                .addObject("queue", queue)
                .addObject("delay", (delay != null ? delay.setPrefix("Delay") : null))
                .addObject("script", script)
                .addObject("context", context);
    }
View Full Code Here

Examples of net.fortuna.ical4j.model.property.Duration

  private KalendarEvent getKalendarEvent(VEvent event) {
    // subject
    String subject = event.getSummary().getValue();
    // start
    Date start = event.getStartDate().getDate();
    Duration dur = event.getDuration();
    // end
    Date end = null;
    if (dur != null) {
      end = dur.getDuration().getTime(event.getStartDate().getDate());
    } else {
      end = event.getEndDate().getDate();
    }

    // check all day event first
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.