[#5642] Add DSL.localDate() localTime() localDateTime() offsetTime() offsetDateTime()

This commit is contained in:
lukaseder 2016-11-06 11:33:00 +01:00
parent a3bb473e86
commit cef5e615db
3 changed files with 175 additions and 1 deletions

View File

@ -10,6 +10,21 @@ http://www.jooq.org/notes
For a text version, see
http://www.jooq.org/inc/RELEASENOTES.txt
Version 3.8.6 - November 4, 2016
================================================================================
This is a patch release with some useful fixes for the 3.8 branch
Features and Improvements
-------------------------
#5628 - Added hint for m2e to behave
#5635 - Further improve select() Javadoc for empty argument lists
Bug Fixes
---------
#5634 - Regression when reading PostgreSQL bytea[] type
Version 3.8.5 - October 21, 2016
================================================================================

View File

@ -83,6 +83,7 @@ import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
@ -12087,6 +12088,164 @@ public class DSL {
return new DateOrTime<Timestamp>(field, SQLDataType.TIMESTAMP);
}
/**
* Convert a string value to a <code>DATE</code>.
*/
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
public static Field<LocalDate> localDate(String value) {
return Tools.field(Convert.convert(value, LocalDate.class), LocalDate.class);
}
/**
* Convert a temporal value to a <code>DATE</code>.
*/
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
public static Field<LocalDate> localDate(LocalDate value) {
return localDate(Tools.field(value));
}
/**
* Convert a temporal value to a <code>DATE</code>.
*/
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
public static Field<LocalDate> localDate(Field<LocalDate> field) {
return new DateOrTime<LocalDate>(field, SQLDataType.LOCALDATE);
}
/**
* Convert a string value to a <code>TIME</code>.
*/
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
public static Field<LocalTime> localTime(String value) {
return Tools.field(Convert.convert(value, LocalTime.class), LocalTime.class);
}
/**
* Convert a temporal value to a <code>TIME</code>.
*/
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
public static Field<LocalTime> localTime(LocalTime value) {
return localTime(Tools.field(value));
}
/**
* Convert a temporal value to a <code>TIME</code>.
*/
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
public static Field<LocalTime> localTime(Field<LocalTime> field) {
return new DateOrTime<LocalTime>(field, SQLDataType.LOCALTIME);
}
/**
* Convert a string value to a <code>TIMESTAMP</code>.
*/
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
public static Field<LocalDateTime> localDateTime(String value) {
return Tools.field(Convert.convert(value, LocalDateTime.class), LocalDateTime.class);
}
/**
* Convert a temporal value to a <code>TIMESTAMP</code>.
*/
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
public static Field<LocalDateTime> localDateTime(LocalDateTime value) {
return localDateTime(Tools.field(value));
}
/**
* Convert a temporal value to a <code>TIMESTAMP</code>.
*/
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
public static Field<LocalDateTime> localDateTime(Field<LocalDateTime> field) {
return new DateOrTime<LocalDateTime>(field, SQLDataType.LOCALDATETIME);
}
/**
* Convert a string value to a <code>TIME WITH TIME ZONE</code>.
* <p>
* Depending on whether the database preserves the time zone information
* (e.g. {@link SQLDialect#ORACLE}) or not (e.g.
* {@link SQLDialect#POSTGRES}), the resulting value might be converted to
* UTC. Regardless of this fact, the result should be the same
* {@link Instant} (in UTC) as the input.
*/
@Support({ POSTGRES })
public static Field<OffsetTime> offsetTime(String value) {
return Tools.field(Convert.convert(value, OffsetTime.class), OffsetTime.class);
}
/**
* Convert a temporal value to a <code>TIME WITH TIME ZONE</code>.
* <p>
* Depending on whether the database preserves the time zone information
* (e.g. {@link SQLDialect#ORACLE}) or not (e.g.
* {@link SQLDialect#POSTGRES}), the resulting value might be converted to
* UTC. Regardless of this fact, the result should be the same
* {@link Instant} (in UTC) as the input.
*/
@Support({ POSTGRES })
public static Field<OffsetTime> offsetTime(OffsetTime value) {
return offsetTime(Tools.field(value));
}
/**
* Convert a temporal value to a <code>TIME WITH TIME ZONE</code>.
* <p>
* Depending on whether the database preserves the time zone information
* (e.g. {@link SQLDialect#ORACLE}) or not (e.g.
* {@link SQLDialect#POSTGRES}), the resulting value might be converted to
* UTC. Regardless of this fact, the result should be the same
* {@link Instant} (in UTC) as the input.
*/
@Support({ POSTGRES })
public static Field<OffsetTime> offsetTime(Field<OffsetTime> field) {
return new DateOrTime<OffsetTime>(field, SQLDataType.OFFSETTIME);
}
/**
* Convert a string value to a <code>TIMESTAMP WITH TIME ZONE</code>.
* <p>
* Depending on whether the database preserves the time zone information
* (e.g. {@link SQLDialect#ORACLE}) or not (e.g.
* {@link SQLDialect#POSTGRES}), the resulting value might be converted to
* UTC. Regardless of this fact, the result should be the same
* {@link Instant} (in UTC) as the input.
*/
@Support({ POSTGRES })
public static Field<OffsetDateTime> offsetDateTime(String value) {
return Tools.field(Convert.convert(value, OffsetDateTime.class), OffsetDateTime.class);
}
/**
* Convert a temporal value to a <code>TIMESTAMP WITH TIME ZONE</code>.
* <p>
* Depending on whether the database preserves the time zone information
* (e.g. {@link SQLDialect#ORACLE}) or not (e.g.
* {@link SQLDialect#POSTGRES}), the resulting value might be converted to
* UTC. Regardless of this fact, the result should be the same
* {@link Instant} (in UTC) as the input.
*/
@Support({ POSTGRES })
public static Field<OffsetDateTime> offsetDateTime(OffsetDateTime value) {
return offsetDateTime(Tools.field(value));
}
/**
* Convert a temporal value to a <code>TIMESTAMP WITH TIME ZONE</code>.
* <p>
* Depending on whether the database preserves the time zone information
* (e.g. {@link SQLDialect#ORACLE}) or not (e.g.
* {@link SQLDialect#POSTGRES}), the resulting value might be converted to
* UTC. Regardless of this fact, the result should be the same
* {@link Instant} (in UTC) as the input.
*/
@Support({ POSTGRES })
public static Field<OffsetDateTime> offsetDateTime(Field<OffsetDateTime> field) {
return new DateOrTime<OffsetDateTime>(field, SQLDataType.OFFSETDATETIME);
}
/**
* Parse a value to a <code>DATE</code>.
*

View File

@ -54,7 +54,7 @@ import org.jooq.QueryPart;
/**
* @author Lukas Eder
*/
final class DateOrTime<T extends java.util.Date> extends AbstractFunction<T> {
final class DateOrTime<T> extends AbstractFunction<T> {
/**
* Generated UID