Home » SQL & PL/SQL » SQL & PL/SQL » Why are these different?
Why are these different? [message #203872] Thu, 16 November 2006 14:25 Go to next message
Duane
Messages: 581
Registered: December 2002
Senior Member
Rounding issue? They return similar but different values.

htp.print(trunc((sysdate - to_date('01-01-1970','dd-mm-yyyy'))*24*60*60));

htp.print(getTime);

Output:
1163687199 
1163708799 


Java Code for getTime:

CREATE OR REPLACE function getTime
RETURN VARCHAR2 AS LANGUAGE JAVA
NAME 'timeFormat.getTimeFormat() return java.lang.String';
/


CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "timeFormat" AS
import java.util.*;


public class timeFormat 
  {  
    public String getTimeFormat(Date time) 
	  {
       // Create a buffer in which to format the data to sign.
	   
       StringBuffer buffer = new StringBuffer();
		
       // Add the appropriately formatted time stamp. Note that
       // the time stamp is expressed in seconds, not milliseconds.

       buffer.append(time.getTime() / 1000);
        
       return buffer.toString();
      }

   public static String getTimeFormat()
     {
      timeFormat timeFormat = new timeFormat(); 
      Date now = new Date(); 
      String returnValue = timeFormat.getTimeFormat(now);
      return returnValue;
     }
  }
;
/

[Updated on: Thu, 16 November 2006 14:27]

Report message to a moderator

Re: Why are these different? [message #203895 is a reply to message #203872] Thu, 16 November 2006 21:00 Go to previous message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
I think the first one is offset from 1/1/1970 in YOUR LOCAL TIME ZONE, and the other is UTC (GMT).

Ross Leishman
Previous Topic: UTL_FILE Package, INVALID_OPERATION Exception. ~~@~~
Next Topic: how can increment one record in cursor
Goto Forum:
  


Current Time: Tue Dec 03 05:17:08 CST 2024