gpt4 book ai didi

org.jooq.types.YearToMonth类的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 03:19:31 25 4
gpt4 key购买 nike

本文整理了Java中org.jooq.types.YearToMonth类的一些代码示例,展示了YearToMonth类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YearToMonth类的具体详情如下:
包路径:org.jooq.types.YearToMonth
类名称:YearToMonth

YearToMonth介绍

[英]An implementation for the SQL standard INTERVAL YEAR TO MONTH data type.

YearToMonth is a Number whose Number#intValue()represents the number of months of the interval.

Note: only a few databases actually support this data type on its own. You can still use it for date time arithmetic in other databases, though, through Field#add(Field) and Field#sub(Field) Databases that have been observed to natively support INTERVAL data types are:

  • SQLDialect#HSQLDB
  • SQLDialect#INGRES
  • SQLDialect#ORACLE
  • SQLDialect#POSTGRES

These dialects have been observed to partially support INTERVAL data types in date time arithmetic functions, such as TIMESTAMPADD, and TIMESTAMPDIFF:

  • SQLDialect#CUBRID
  • SQLDialect#MARIADB
  • SQLDialect#MYSQL
    [中]SQL标准INTERVAL YEAR TO MONTH数据类型的实现。
    YearToMonth是一个数字,其数字#intValue()表示间隔的月数。
    注意:只有少数数据库本身支持这种数据类型。您仍然可以在其他数据库中使用它进行日期-时间算法,不过,通过观察到本机支持INTERVAL数据类型的字段#添加(字段)和字段#子(字段)数据库:
    *Sql方言#HSQLDB
    *SQL方言#安格尔
    *SQL方言#甲骨文
    *SQL方言#博士后
    据观察,这些方言部分支持日期时间算术函数中的INTERVAL数据类型,例如TIMESTAMPADD和[$5$]:
    *Sql方言#CUBRID
    *Sql方言#MARIADB
    *SQL方言#MYSQL

代码示例

代码示例来源:origin: org.jooq/jooq

@Override
public final YearToMonth abs() {
  return new YearToMonth(years, months, false);
}

代码示例来源:origin: org.jooq/jooq

/**
 * Convert a jOOQ <code>YEAR TO MONTH</code> interval to a Postgres representation
 */
public static Object toPGInterval(YearToMonth interval) {
  return on("org.postgresql.util.PGInterval").create(
    interval.getSign() * interval.getYears(),
    interval.getSign() * interval.getMonths(),
    0, 0, 0, 0.0).get();
}

代码示例来源:origin: org.jooq/jooq

@Override
public final long longValue() {
  return intValue();
}

代码示例来源:origin: org.jooq/jooq

/**
 * 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;
}

代码示例来源:origin: org.jooq/jooq

@Override
final YearToMonth get0(BindingGetSQLInputContext<U> ctx) throws SQLException {
  String string = ctx.input().readString();
  return string == null ? null : YearToMonth.valueOf(string);
}

代码示例来源:origin: org.jooq/jooq

@Override
final void set0(BindingSetSQLOutputContext<U> ctx, YearToMonth value) throws SQLException {
  ctx.output().writeString(value.toString());
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * 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;
}

代码示例来源:origin: org.jooq/jooq

private static final Interval parseIntervalLiteral(ParserContext ctx) {
  String string = parseStringLiteral(ctx);
  DayToSecond ds = DayToSecond.valueOf(string);
  if (ds != null)
    return ds;
  YearToMonth ym = YearToMonth.valueOf(string);
  if (ym != null)
    return ym;
  throw ctx.exception("Illegal interval literal");
}

代码示例来源:origin: org.jooq/jooq

@Override
final void set0(BindingSetStatementContext<U> ctx, YearToMonth value) throws SQLException {
  // [#566] Interval data types are best bound as Strings
  if (ctx.family() == POSTGRES)
    ctx.statement().setObject(ctx.index(), toPGInterval(value));
  else
    ctx.statement().setString(ctx.index(), value.toString());
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Convert a jOOQ <code>YEAR TO MONTH</code> interval to a Postgres representation
 */
public static Object toPGInterval(YearToMonth interval) {
  return on("org.postgresql.util.PGInterval").create(
    interval.getSign() * interval.getYears(),
    interval.getSign() * interval.getMonths(),
    0, 0, 0, 0.0).get();
}

代码示例来源:origin: org.jooq/jooq

@Override
final YearToMonth get0(BindingGetStatementContext<U> ctx) throws SQLException {
  if (ctx.family() == POSTGRES) {
    Object object = ctx.statement().getObject(ctx.index());
    return object == null ? null : PostgresUtils.toYearToMonth(object);
  }
  else {
    String string = ctx.statement().getString(ctx.index());
    return string == null ? null : YearToMonth.valueOf(string);
  }
}

代码示例来源:origin: org.jooq/jooq

@Override
public final float floatValue() {
  return intValue();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

@Override
public final YearToMonth neg() {
  return new YearToMonth(years, months, !negative);
}

代码示例来源:origin: org.jooq/jooq

@Override
final YearToMonth get0(BindingGetResultSetContext<U> ctx) throws SQLException {
  if (ctx.family() == POSTGRES) {
    Object object = ctx.resultSet().getObject(ctx.index());
    return object == null ? null : PostgresUtils.toYearToMonth(object);
  }
  else {
    String string = ctx.resultSet().getString(ctx.index());
    return string == null ? null : YearToMonth.valueOf(string);
  }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

@Override
public final float floatValue() {
  return intValue();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

@Override
public final YearToMonth abs() {
  return new YearToMonth(years, months, false);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

return (T) (string == null ? null : YearToMonth.valueOf(string));

代码示例来源:origin: org.jooq/jooq

@Override
public final double doubleValue() {
  return intValue();
}

代码示例来源:origin: org.jooq/jooq

@Override
public final YearToMonth neg() {
  return new YearToMonth(years, months, !negative);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

return (T) (string == null ? null : YearToMonth.valueOf(string));

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com