Package org.jooq.types

Examples of org.jooq.types.YearToMonth


    }

    @Test
    public void testYearToMonth() {
        for (int i = 0; i <= 5; i++) {
            intervalChecks(i * 12, new YearToMonth(i));
            intervalChecks(i * -12, new YearToMonth(i).neg());
            intervalChecks(i, new YearToMonth(0, i));
        }
    }
View Full Code Here


        assertEquals(expected.shortValue(), interval.shortValue());
        assertEquals(expected.intValue(), interval.intValue());
        assertEquals(expected.longValue(), interval.longValue());

        if (interval instanceof YearToMonth) {
            YearToMonth y = YearToMonth.valueOf(interval.toString());
            assertEquals(interval, y);
        }
        else {
            DayToSecond m = DayToSecond.valueOf(interval.toString());
            assertEquals(interval, m);
View Full Code Here

        // Other dialects support actual interval data types
        else {
            record =
            create().select(
                val(new YearToMonth(1, 1)).as("iyplus"),
                val(new YearToMonth(0)).as("iy"),
                val(new YearToMonth(1, 1).neg()).as("iyminus"),

                val(new DayToSecond(1, 1, 1, 1)).as("idplus"),
                val(new DayToSecond(0)).as("id"),
                val(new DayToSecond(1, 1, 1, 1).neg()).as("idminus")
            ).fetchOne();

            assertEquals(new YearToMonth(1, 1), record.getValue("iyplus"));
            assertEquals(new YearToMonth(0), record.getValue("iy"));
            assertEquals(new YearToMonth(1, 1).neg(), record.getValue("iyminus"));

            assertEquals(new DayToSecond(1, 1, 1, 1), record.getValue("idplus"));
            assertEquals(new DayToSecond(0), record.getValue("id"));
            assertEquals(new DayToSecond(1, 1, 1, 1).neg(), record.getValue("idminus"));
            // TODO: Add tests for reading date / time / interval types into pojos

            // [#566] INTERVAL arithmetic: multiplication
            // ------------------------------------------
            record =
            create().select(
                val(new YearToMonth(1)).div(2).as("y1"),
                val(new YearToMonth(1)).mul(2).as("y2"),
                val(new YearToMonth(1)).div(2).mul(2).as("y3"),

                val(new DayToSecond(1)).div(2).as("d1"),
                val(new DayToSecond(1)).mul(2).as("d2"),
                val(new DayToSecond(1)).div(2).mul(2).as("d3")
            ).fetchOne();

            assertEquals(new YearToMonth(0, 6), record.getValue("y1"));
            assertEquals(new YearToMonth(2), record.getValue("y2"));
            assertEquals(new YearToMonth(1), record.getValue("y3"));

            assertEquals(new DayToSecond(0, 12), record.getValue("d1"));
            assertEquals(new DayToSecond(2), record.getValue("d2"));
            assertEquals(new DayToSecond(1), record.getValue("d3"));
        }
View Full Code Here

            val(new Date(0)).add(1).as("d1"),
            dateAdd(new Date(0), 1).as("d1a"),
            val(new Date(0)).add(-1).as("d2a"),
            val(new Date(0)).sub(1).as("d2b"),

            val(new Date(0)).add(new YearToMonth(1, 6)).as("d3"),
            dateAdd(new Date(0), new YearToMonth(1, 6)).as("d3a"),
            val(new Date(0)).add(new YearToMonth(1, 6).neg()).as("d4a"),
            val(new Date(0)).sub(new YearToMonth(1, 6)).as("d4b"),

            val(new Date(0)).add(new DayToSecond(2)).as("d5"),
            dateAdd(new Date(0), new DayToSecond(2)).as("d5a"),
            val(new Date(0)).add(new DayToSecond(2).neg()).as("d6a"),
            val(new Date(0)).sub(new DayToSecond(2)).as("d6b"),

            val(new Timestamp(0)).add(1).as("ts1"),
            timestampAdd(new Timestamp(0), 1).as("ts1a"),
            val(new Timestamp(0)).add(-1).as("ts2a"),
            val(new Timestamp(0)).sub(1).as("ts2b"),

            val(new Timestamp(0)).add(new YearToMonth(1, 6)).as("ts3"),
            timestampAdd(new Timestamp(0), new YearToMonth(1, 6)).as("ts3a"),
            val(new Timestamp(0)).add(new YearToMonth(1, 6).neg()).as("ts4a"),
            val(new Timestamp(0)).sub(new YearToMonth(1, 6)).as("ts4b"),

            val(new Timestamp(0)).add(new DayToSecond(2)).as("ts5"),
            timestampAdd(new Timestamp(0), new DayToSecond(2)).as("ts5a"),
            val(new Timestamp(0)).add(new DayToSecond(2).neg()).as("ts6a"),
            val(new Timestamp(0)).sub(new DayToSecond(2)).as("ts6b"),
View Full Code Here

    }

    @Test
    public void testYearToMonth() {
        for (int i = 0; i <= 5; i++) {
            intervalChecks(i * 12, new YearToMonth(i));
            intervalChecks(i * -12, new YearToMonth(i).neg());
            intervalChecks(i, new YearToMonth(0, i));
        }
    }
View Full Code Here

        assertEquals(expected.shortValue(), interval.shortValue());
        assertEquals(expected.intValue(), interval.intValue());
        assertEquals(expected.longValue(), interval.longValue());

        if (interval instanceof YearToMonth) {
            YearToMonth y = YearToMonth.valueOf(interval.toString());
            assertEquals(interval, y);
        }
        else {
            DayToSecond m = DayToSecond.valueOf(interval.toString());
            assertEquals(interval, m);
View Full Code Here

        Reflect i = on(pgInterval);
        if (negative) {
            i.call("scale", -1);
        }

        YearToMonth result = new YearToMonth(
            i.call("getYears").<Integer>get(),
            i.call("getMonths").<Integer>get());

        if (negative) {
            result = result.neg();
        }

        return result;
    }
View Full Code Here

        Reflect i = on(pgInterval);
        if (negative) {
            i.call("scale", -1);
        }

        YearToMonth result = new YearToMonth(
            i.call("getYears").<Integer>get(),
            i.call("getMonths").<Integer>get());

        if (negative) {
            result = result.neg();
        }

        return result;
    }
View Full Code Here

TOP

Related Classes of org.jooq.types.YearToMonth

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.