org.h2.mode
Class FunctionsMySQL

java.lang.Object
  extended by org.h2.mode.FunctionsMySQL

public class FunctionsMySQL
extends java.lang.Object

This class implements some MySQL-specific functions.


Constructor Summary
FunctionsMySQL()
           
 
Method Summary
static java.lang.String date(java.lang.String dateTime)
          See http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date This function is dependent on the exact formatting of the MySQL date/time string.
static java.lang.String fromUnixTime(int seconds)
          See http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_from-unixtime
static java.lang.String fromUnixTime(int seconds, java.lang.String format)
          See http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_from-unixtime
static void register(java.sql.Connection conn)
          Register the functionality in the database.
static int unixTimestamp()
          Get the seconds since 1970-01-01 00:00:00 UTC.
static int unixTimestamp(java.sql.Timestamp timestamp)
          Get the seconds since 1970-01-01 00:00:00 UTC of the given timestamp.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FunctionsMySQL

public FunctionsMySQL()
Method Detail

register

public static void register(java.sql.Connection conn)
                     throws java.sql.SQLException
Register the functionality in the database. Nothing happens if the functions are already registered.

Parameters:
conn - the connection
Throws:
java.sql.SQLException

unixTimestamp

public static int unixTimestamp()
Get the seconds since 1970-01-01 00:00:00 UTC. See http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_unix-timestamp

Returns:
the current timestamp in seconds (not milliseconds).

unixTimestamp

public static int unixTimestamp(java.sql.Timestamp timestamp)
Get the seconds since 1970-01-01 00:00:00 UTC of the given timestamp. See http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_unix-timestamp

Parameters:
timestamp - the timestamp
Returns:
the current timestamp in seconds (not milliseconds).

fromUnixTime

public static java.lang.String fromUnixTime(int seconds)
See http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_from-unixtime

Parameters:
seconds - The current timestamp in seconds.
Returns:
a formatted date/time String in the format "yyyy-MM-dd HH:mm:ss".

fromUnixTime

public static java.lang.String fromUnixTime(int seconds,
                                            java.lang.String format)
See http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_from-unixtime

Parameters:
seconds - The current timestamp in seconds.
format - The format of the date/time String to return.
Returns:
a formatted date/time String in the given format.

date

public static java.lang.String date(java.lang.String dateTime)
See http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date This function is dependent on the exact formatting of the MySQL date/time string.

Parameters:
dateTime - The date/time String from which to extract just the date part.
Returns:
the date part of the given date/time String argument.