Examples of MutableDateTime


Examples of org.joda.time.MutableDateTime

        assertEquals(new MutableDateTime(2004, 2, 29, 23, 59, 59, 999, TOKYO), result);
    }

    public void testParseInto_monthDay_withDefaultYear_feb29() {
        DateTimeFormatter f = DateTimeFormat.forPattern("M d").withDefaultYear(2012);
        MutableDateTime result = new MutableDateTime(2004, 1, 9, 12, 20, 30, 0, LONDON);
        assertEquals(4, f.parseInto(result, "2 29", 0));
        assertEquals(new MutableDateTime(2004, 2, 29, 12, 20, 30, 0, LONDON), result);
    }
View Full Code Here

Examples of org.joda.time.MutableDateTime

        assertEquals(new MutableDateTime(2004, 2, 29, 12, 20, 30, 0, LONDON), result);
    }

    public void testParseInto_monthDay_withDefaultYear_feb29_newYork() {
        DateTimeFormatter f = DateTimeFormat.forPattern("M d").withDefaultYear(2012);
        MutableDateTime result = new MutableDateTime(2004, 1, 9, 12, 20, 30, 0, NEWYORK);
        assertEquals(4, f.parseInto(result, "2 29", 0));
        assertEquals(new MutableDateTime(2004, 2, 29, 12, 20, 30, 0, NEWYORK), result);
    }
View Full Code Here

Examples of org.joda.time.MutableDateTime

        assertEquals(new MutableDateTime(2004, 2, 29, 12, 20, 30, 0, NEWYORK), result);
    }

    public void testParseInto_monthDay_withDefaultYear_feb29_newYork_endOfYear() {
        DateTimeFormatter f = DateTimeFormat.forPattern("M d").withDefaultYear(2012);
        MutableDateTime result = new MutableDateTime(2004, 12, 9, 12, 20, 30, 0, NEWYORK);
        assertEquals(4, f.parseInto(result, "2 29", 0));
        assertEquals(new MutableDateTime(2004, 2, 29, 12, 20, 30, 0, NEWYORK), result);
    }
View Full Code Here

Examples of org.joda.time.MutableDateTime

    }

    public void testWeekdayNames() {
        DateTimeFormatter printer = DateTimeFormat.forPattern("EEEE");
        for (int i=0; i<ZONES.length; i++) {
            MutableDateTime mdt = new MutableDateTime(2004, 1, 1, 1, 20, 30, 40, ZONES[i]);
            for (int day=1; day<=366; day++) {
                mdt.setDayOfYear(day);
                int weekday = mdt.getDayOfWeek();
                String weekdayText = printer.print(mdt);
                assertEquals(WEEKDAYS[weekday], weekdayText);
            }
        }
    }
View Full Code Here

Examples of org.joda.time.MutableDateTime

    public void testHalfdayNames() {
        DateTimeFormatter printer = DateTimeFormat.forPattern("a");
        for (int i=0; i<ZONES.length; i++) {
            Chronology chrono = ISOChronology.getInstance(ZONES[i]);
            MutableDateTime mdt = new MutableDateTime(2004, 5, 30, 0, 20, 30, 40, chrono);
            for (int hour=0; hour<24; hour++) {
                mdt.setHourOfDay(hour);
                int halfday = mdt.get(chrono.halfdayOfDay());
                String halfdayText = printer.print(mdt);
                assertEquals(HALFDAYS[halfday], halfdayText);
            }
        }
    }
View Full Code Here

Examples of org.joda.time.MutableDateTime

        assertEquals(expect, g.withChronology(BUDDHIST_PARIS).parseDateTime("2004-06-09T10:20:30Z"));
    }

    //-----------------------------------------------------------------------
    public void testParseMutableDateTime_simple() {
        MutableDateTime expect = null;
        expect = new MutableDateTime(2004, 6, 9, 11, 20, 30, 0, LONDON);
        assertEquals(expect, g.parseMutableDateTime("2004-06-09T10:20:30Z"));
       
        try {
            g.parseMutableDateTime("ABC");
            fail();
View Full Code Here

Examples of org.joda.time.MutableDateTime

            fail();
        } catch (IllegalArgumentException ex) {}
    }

    public void testParseMutableDateTime_zone() {
        MutableDateTime expect = null;
        expect = new MutableDateTime(2004, 6, 9, 11, 20, 30, 0, LONDON);
        assertEquals(expect, g.withZone(LONDON).parseMutableDateTime("2004-06-09T10:20:30Z"));
       
        expect = new MutableDateTime(2004, 6, 9, 11, 20, 30, 0, LONDON);
        assertEquals(expect, g.withZone(null).parseMutableDateTime("2004-06-09T10:20:30Z"));
       
        expect = new MutableDateTime(2004, 6, 9, 12, 20, 30, 0, PARIS);
        assertEquals(expect, g.withZone(PARIS).parseMutableDateTime("2004-06-09T10:20:30Z"));
    }
View Full Code Here

Examples of org.joda.time.MutableDateTime

            from = new DateTime(Long.parseLong(firstTimestamp) * 1000, DateTimeZone.UTC);
        } else {
            from = DateTime.parse(histogram.getHistogramBoundaries().getFrom());
        }
        final DateTime to = DateTime.parse(histogram.getHistogramBoundaries().getTo());
        final MutableDateTime currentTime = new MutableDateTime(from);

        final Duration step = estimateIntervalStep(histogram.getInterval());
        final int dataPoints = (int) ((to.getMillis() - from.getMillis()) / step.getMillis());

        // using the absolute value guarantees, that there will always be enough values for the given resolution
        final int factor = (maxDataPoints != -1 && dataPoints > maxDataPoints) ? dataPoints / maxDataPoints : 1;

        int index = 0;
        floorToBeginningOfInterval(histogram.getInterval(), currentTime);
        while (currentTime.isBefore(to) || currentTime.isEqual(to)) {
            if (index % factor == 0) {
                String timestamp = Long.toString(currentTime.getMillis() / 1000);
                Long result = histogramResults.get(timestamp);
                Map<String, Long> point = Maps.newHashMap();
                point.put("x", Long.parseLong(timestamp));
                point.put("y", result != null ? result : 0);
                points.add(point);
View Full Code Here

Examples of org.joda.time.MutableDateTime

        assertEquals(ISO, ReadableInstantConverter.INSTANCE.getChronology(new Instant(123L), (DateTimeZone) null));
        assertEquals(ISO, ReadableInstantConverter.INSTANCE.getChronology(new DateTime(123L), (DateTimeZone) null));
       
        assertEquals(ISO_PARIS, ReadableInstantConverter.INSTANCE.getChronology(new DateTime(123L, new MockBadChronology()), PARIS));
       
        MutableDateTime mdt = new MutableDateTime() {
            public Chronology getChronology() {
                return null; // bad
            }
        };
        assertEquals(ISO_PARIS, ReadableInstantConverter.INSTANCE.getChronology(mdt, PARIS));
View Full Code Here

Examples of org.joda.time.MutableDateTime

    public void testGetChronology_Object_nullChronology() throws Exception {
        assertEquals(ISO.withUTC(), ReadableInstantConverter.INSTANCE.getChronology(new Instant(123L), (Chronology) null));
        assertEquals(ISO, ReadableInstantConverter.INSTANCE.getChronology(new DateTime(123L), (Chronology) null));
       
        MutableDateTime mdt = new MutableDateTime() {
            public Chronology getChronology() {
                return null; // bad
            }
        };
        assertEquals(ISO, ReadableInstantConverter.INSTANCE.getChronology(mdt, (Chronology) null));
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.