Search in sources :

Example 1 with Reflect

use of org.jooq.tools.reflect.Reflect in project jOOQ by jOOQ.

the class PostgresUtils method toYearToMonth.

/**
     * Convert a Postgres interval to a jOOQ <code>YEAR TO MONTH</code> interval
     */
public static YearToMonth toYearToMonth(Object pgInterval) {
    boolean negative = pgInterval.toString().contains("-");
    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;
}
Also used : Reflect(org.jooq.tools.reflect.Reflect) YearToMonth(org.jooq.types.YearToMonth)

Example 2 with Reflect

use of org.jooq.tools.reflect.Reflect in project jOOQ by jOOQ.

the class PostgresUtils method toDayToSecond.

/**
     * Convert a Postgres interval to a jOOQ <code>DAY TO SECOND</code> interval
     */
public static DayToSecond toDayToSecond(Object pgInterval) {
    boolean negative = pgInterval.toString().contains("-");
    Reflect i = on(pgInterval);
    if (negative) {
        i.call("scale", -1);
    }
    Double seconds = i.call("getSeconds").<Double>get();
    DayToSecond result = new DayToSecond(i.call("getDays").<Integer>get(), i.call("getHours").<Integer>get(), i.call("getMinutes").<Integer>get(), seconds.intValue(), (int) (1000000000 * (seconds - seconds.intValue())));
    if (negative) {
        result = result.neg();
    }
    return result;
}
Also used : Reflect(org.jooq.tools.reflect.Reflect) DayToSecond(org.jooq.types.DayToSecond)

Aggregations

Reflect (org.jooq.tools.reflect.Reflect)2 DayToSecond (org.jooq.types.DayToSecond)1 YearToMonth (org.jooq.types.YearToMonth)1