All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jooq.types.Interval Maven / Gradle / Ivy

There is a newer version: 3.19.11
Show newest version
/**
 * Copyright (c) 2009-2016, Data Geekery GmbH (http://www.datageekery.com)
 * All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Other licenses:
 * -----------------------------------------------------------------------------
 * Commercial licenses for this work are available. These replace the above
 * ASL 2.0 and offer limited warranties, support, maintenance, and commercial
 * database integrations.
 *
 * For more information, please visit: http://www.jooq.org/licenses
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */
package org.jooq.types;

import java.io.Serializable;

import org.jooq.Field;
import org.jooq.SQLDialect;

/**
 * A substitute for JDBC's missing java.sql.Interval data type.
 * 

* JDBC lacks an important data type that is present in most SQL databases: * INTERVAL. The SQL:2008 standard states that there are two types * of intervals:

4.6.3 Intervals *

* There are two classes of intervals. One class, called year-month intervals, * has an express or implied datetime precision that includes no fields other * than YEAR and MONTH, though not both are required. The other class, called * day-time intervals, has an express or implied interval precision that can * include any fields other than YEAR or MONTH.

*

* INTERVAL can be combined with date time data types according to * the following operation table: *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Operand 1OperatorOperand 2Result Type
DatetimeDatetimeInterval
Datetime+ or –IntervalDatetime
Interval+DatetimeDatetime
Interval+ or –IntervalInterval
Interval* or /NumericInterval
Numeric*IntervalInterval
*

* Interval implementations can be expected to also also extend {@link Number}. *

* 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 * {@link Field#add(Field)} and {@link Field#sub(Field)} Databases that have * been observed to natively support INTERVAL data types are: *

    *
  • {@link SQLDialect#HSQLDB}
  • *
  • {@link SQLDialect#INGRES}
  • *
  • {@link SQLDialect#ORACLE}
  • *
  • {@link SQLDialect#POSTGRES}
  • *
*

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

    *
  • {@link SQLDialect#CUBRID}
  • *
  • {@link SQLDialect#MARIADB}
  • *
  • {@link SQLDialect#MYSQL}
  • *
* * @author Lukas Eder */ public interface Interval extends Serializable { /** * Negate the interval (change its sign) */ Interval neg(); /** * Get the absolute value of the interval (set its sign to positive) */ Interval abs(); /** * The sign of the interval * * @return 1 for positive or zero, -1 for negative */ int getSign(); /** * @see Number#doubleValue() */ double doubleValue(); /** * @see Number#floatValue() */ float floatValue(); /** * @see Number#longValue() */ long longValue(); /** * @see Number#intValue() */ int intValue(); /** * @see Number#byteValue() */ byte byteValue(); /** * @see Number#shortValue() */ short shortValue(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy