A simple Oracle function that returns a Date in EPOCH format using java.lang.System.currentTimeMillis()

By Ken Fitzpatrick

EPOCH Date format, otherwise known as Unix or POSIX time is used when transferring dates between different systems (.Net to Java systems) and/or systems in different time zones. It is defined by wikipedia as "the number of seconds elapsed since midnight proleptic Coordinated Universal Time (UTC) of January 1, 1970, not counting leap seconds." This function also illustrates the use of the java libraries from Oracle procedures and functions.

create or replace function epoch_ms
   return number
as
   language java
   name 'java.lang.System.currentTimeMillis()return int';

A simple Oracle function that returns a Date in EPOCH format using java.lang.System.currentTimeMillis()  (1138 Views)