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;
}
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;
}
Aggregations