Time from UNIX epoch

I have the number of micro seconds from the UNIX epoch time 00:00:00 UTC 1
Jan 1970. (1092727073895638 usec)
I want to know the time in CST.
I have been trying to work with the Calendar class and GregorianCalendar.
But I am not quite getting it. Could someone give me an idea of what I need
to do.
Thanks
Ox

You need to set a TimeZone in your Calendar or GregorianCalendar. Then format using SimpleDateFormat. Post the code that you tried, and explain what isn't coming out correctly.

Similar Messages

  • How to return start and end time in Unix epoch format

    Hi: I have a integer field (utime) in a table that stores the UNIX epoch time for a record. Every sunday around 2:00AM, I am running a query which should return records from last week. I want my condition to have the following in it's where
    WHERE utime between
    (convert sysdate-7 12:00AM to Unix time)
    AND
    (convert yesterday 11:59PM to Unix time)
    Can someone help me create this convert?
    Thanks
    Ray

    Yes, you seem to have worked out the logic of the expression correctly. Though, in your earlier post you had said that you want records within the range:
    WHERE utime between
    (convert sysdate-7 12:00AM to Unix time)
    AND
    (convert yesterday 11:59PM to Unix time)But now you are adding 14400 (4hrs) and deducting 72000 (20hrs) in your expression
    SELECT * from TABLE
    WHERE utime between
    ((TRUNC(SYSDATE,'DD')-TO_DATE('01/01/1970','MM/DD/YYYY'))*(24*60*60))+14400 AND
    ((TRUNC(SYSDATE-6,'DD')-TO_DATE('01/01/1970','MM/DD/YYYY'))*(24*60*60))-72000;Which makes your new condition to be:
    WHERE utime between
    (convert sysdate 04:00AM to Unix time)
    AND
    (convert sysdate-7 04:00AM to Unix time)
    Are you sure you need records from 4am-to-4am and not midnight-to-midnight? And yes, with BETWEEN condition you need to use expression '<low-value> AND <high-value>' and not '<high-value> AND <low-value>'!
    Besides this,
    1. You might want to use bind variables rather than hard-coded expressions in your statement. Infact your expression uses SYSDATE, so Oracle would need to get current SYSDATE for each row to evaluate the expression. Which is going to have its impact on performance. As your start-time and end-time values are not dependent on table data maybe you could have a code like this (assuming it is PLSQL code):
    start_time constant number := (convert sysdate-7 12:00AM to Unix time);
    end_time constant number := (convert yesterday 11:59PM to Unix time);
    <DML or Cursor with condition>
    WHERE utime between start_time and end_time;
    2. You said that your table already has values in unix-epoch-time in column 'utime'. How are these values inserted in the first place? Is there a function in your application that converts any given time to unix-epoch-time? Is yes, then use that in your code.
    3. If such a function does not exists, than rather than using hard-coded expressions it might be a good idea to create new functions for converting to and from unix-epoch-time and to get current unix-epoch-time from server.
    Using a function in the above case:
    start_time constant number := f_convert_to_unix_time( trunc( sysdate-7 ));
    end_time constant number := f_convert_to_unix_time( trunc( sysdate )) - 1;
    <DML or Cursor with condition>
    WHERE utime between start_time and end_time;
    And lastly, some of us might not know about Unix time, so here is a useful link http://en.wikipedia.org/wiki/Unix_time

  • Convert date/time to Unix epoch

    I have thousands of date time stamps I would like to convert to Unix epoch ten-digit strings. That is, take some thing like:
    Dec 9, 2005 10:24 AM
    and convert to
    1234567890 (only in the correct unix epoch time)
    What formula can I use? I've found that this "=DATE(1970,1,1)+P2/86400" can convert a 10 string epoch time down to just a date correctly, but without time. But I need to go in the opposite direction, with the time included.
    Using Numbers 09 ver 2.0.5 (368)

    CP,
    An up-to-date Unix Time would be provided by:
    =DUR2SECONDS((NOW()-"1/1/1970"))
    A somewhat more robust form would be:
    =DUR2SECONDS(NOW()-DATE(1970,1,1))
    If the time to be converted is in Cell P2, the expression would be:
    =DUR2SECONDS(P2-DATE(1970,1,1))
    Jerry

  • Conversion of Standard Datetime format to Unix (Epoch) time

    Hi,
    I am having trouble getting efficient record selection for time ranges on DB2 tables that use the UNIX epoch time stamp.
    E.g., for a 1 minute time range we would currently use SQL such as:
    SELECT * FROM DATABASE.TABLE WHERE  ((TIMESTAMP('1970-01-01-00.00.00.000000') + (("EPOCH_TIME" + 3600000)/1000) SECONDS)>={ts '2008-09-04 14:29:00'} AND (TIMESTAMP('1970-01-01-00.00.00.000000') + (("EPOCH_TIME" + 3600000)/1000) SECONDS)<{ts '2008-09-04 14:30:01'})
    This is the equivalent of:
    select * from DATABASE.TABLE where EPOCH_TIME between 1220534940000 and 1220535000000.
    Now clearly the problem is the top SQL doing a calculation for every record (up to 5,000,000 records) to select the data. It takes approximately 5 minutes to return the data. The bottom SQL takes LESS THAN A SECOND.
    Please, please, please could someone help us with this? We need to be able to enter a datetime variable, and have the SQL sent to the DB2 table in the format of the lower SQL above.
    We are using a BO XI Enterprise server to do this.

    OK Everyone.
    This is how to do it:
    Use the following (for Crystal Reports XI)
    DateDiff (intervalType, startDateTime, endDateTime)
    as:
    Datediff ("s",(datetime(date(1970,01,01)),time(00,00,00)),currentdatetime)
    Looks a bit too simple, but does work. Look out for differences between the results due to daylight saving.

  • Read file latest entry with time stamp from unix

    Hi
    I have a log file which is being generated with an entry  like this
    Product20080228185707,TRANSPORTED,862067_G,MPITT,20080415,ADEAMICIS,
    Product 20080229151029,TRANSPORTED,862067_G,MPITT,20080415,ADEAMICIS,
    Product 20080320163241,TRANSPORTED,862067_G,MPITT,20080415,ADEAMICIS,
    Product 20080229151111,TRANSPORTED,862067_G,MPITT,20080415,ADEAMICIS,
    I know how to read the file from Unix but How do I pick the entry with latest time stamp ?
    Please help urgent
    thanks

    Hi,
    Do like this.
    1. Declare table with two fields as name(255) type c, timestamp(14) type n.
    2. Loop at your entries and push entry name in name field and time stamp in timestamp field. You can move time stamp as: move file+7(13) to timestamp.
    3. So your new internal table will have entry names and timestamp.
    4. Now sort itab by timestamp descending.
    5. Read itab index 1.
    this will give you latest entry from unix.
    i hope this helps,
    Ags,

  • How can i get the System Time from the other host

    I want to get the System Time from the other host in the LAN,How can I get the Time using Java.
    Such as I am in WIN 2000 and I have a Unix host in LAN, I want to get unix host System time, How can I do it.

    Open a socket to port 13 and read a string with the time.
    -or-
    Open a socket to port 27 and read 4 bytes that are a network order timestamp
    Assuming that your UNIX machine has those services running, most do

  • Calling a report from unix shell script

    Hi,
    I had to call a report from unix shell script.
    May i know the procedure to accomplish this
    Thanks in Advance
    A.Gopal

    First you should not include the whole path to your report in the call ...
    Use like this:
    /ora/u01/oracle/v101/as2/bin/rwrun.sh report=an_stati destype=file desname=/ora/u01/oracle/v101/as2/test.pdf desformat=pdf
    In $ORACLE_HOME/bin/reports.sh:
    1) Verify that you have updated the REPORTS_PATH variable to include your folder where you have the report in question
    REPORTS_PATH=/ora/u20/app/qits/env1/run:$ORACLE_HOME/reports/templates:$ORACLE_HOME/reports/samples/demo: ....
    2) Verify that the REPORTS_TMP variable is pointing to a valid location and that the oracle user has access to write on it.
    After that, post the content of the tracefile located at $ORACLE_HOME/reports/logs/{in-process report server name folder}/rwserver.trc
    If no file is present then it means that you need to enable trace in your reports's conf file.... go to the $ORACLE_HOME/reports/conf folder and and locate the .conf file that correspond to your in-process reports server name (as specified in the rwservelet.properties file)... open/edit the file to enable trace logs ..
    i.e.
    Change the following line:
    <!--trace traceOpts="trace_all"/-->
    to <trace traceOpts="trace_all"/>
    Bounce the reports server and try to run the report again, this time the .trc file should be generated, post the content so that we can take a look.

  • Using unzip from unix in java-code ...

    Hi people,
    i have problem, i want to use the command unzip from unix, to unzip a zip-file, the commend unzip must invoke from java-code. Can someone help me. I use the zip-api, but i have 100Mb zip-file, it needs very long time to unzip the zip-file.
    thanks for your help ...

    ok, not sure how much improvement this will give in general, but its given a reliable 25% speed increase on my mini tests
    using the nio libraries will also get you a lot further, and is the way to go if you are very keen on speed
    asjf
    import java.awt.*;
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    import javax.swing.*;
    public class Unzipper {
         private Unzipper() {}
         private static byte[] buffer = new byte[16384];
         public static void unzip(File file, Component parentComponent,     File outputDir) throws ZipException, IOException {
              unzip(new ZipFile(file), parentComponent, outputDir);
         public static void unzip(File file, int mode, Component parentComponent, File outputDir) throws IOException {
              unzip(new ZipFile(file, mode), parentComponent, outputDir);
         public static void unzip(String name, Component parentComponent, File outputDir)     throws IOException {
              unzip(new ZipFile(name), parentComponent, outputDir);
         public static void unzip(ZipFile zip, Component parentComponent, File outputDir)     throws IOException {
              if ( zip == null) {
                   throw new NullPointerException("outputDir is null");
              int size = zip.size();
              if (size > 0) {
                   if (outputDir == null) {
                        throw new NullPointerException("outputDir is null");
                   if (!outputDir.exists()) {
                        outputDir.mkdirs();
                   ProgressMonitor monitor =
                   new ProgressMonitor(parentComponent,
                   "Unpacking " + zip.getName() + "...", "", 0, size);
                   monitor.setMillisToDecideToPopup(0);
                   monitor.setMillisToPopup(0);
                   Enumeration entries = zip.entries();
                   for ( int i = 0; entries.hasMoreElements(); ) {
                        ZipEntry entry = (ZipEntry) entries.nextElement();
                        /*if (entry.getMethod() == ZipEntry.DEFLATED)
                        System.out.println(" Inflating: "+entry.getName());
                        else
                        System.out.println(" Extracting: "+entry.getName());*/
                        monitor.setNote(entry.getName());
                        File File = new File(outputDir, entry.getName());
                        File.getParentFile().mkdirs();
                        if (!entry.isDirectory()) {
                             InputStream in = null;
                             OutputStream out = null;
                             try {
                                  in = zip.getInputStream(entry);
                                  out = new FileOutputStream(File);
                                  for (int n = 0; (n = in.read(buffer)) > -1; )
                                       out.write(buffer, 0, n);
                                  monitor.setProgress(++i);
                             } finally {
                                  if (out != null) {
                                       try {
                                            out.close();
                                       } catch (IOException e) {
         public static void main(String[] args) throws ZipException, IOException
              if (args.length !=2) {
                   System.err.println("Usage: java Unzipper <zip file> <output dir>");
                   System.exit(1);
              long start = -System.currentTimeMillis();
              unzip(args[0], null, new File(args[1]));
              System.out.println(start+System.currentTimeMillis());
              System.exit(0);

  • Call ABAP program from Unix script passing dynamic filename

    Hi,
    Does anyone know if it is possible to call an ABAP program from a Unix script passing a dynamic filename to the ABAP program?
    We are receiving a file from an external company and on receipt of the file want to call an ABAP program passing the filename.  The filename is made up of File ID, Date and Time which we need to read in the ABAP program.  We usually use Events to trigger a program which is fine when the filename if static however since this filename will be dynamic we cannot do this.  In addition we cannot just rename the file to a static name in the Unix script as we need to know the value of the date and time from the file ID in the ABAP program.  I can change the ABAP program to check our /in directory for a Filename that starts with the fixed File ID however I thought there must be a better way of doing this.  We want the external company to put this information in a file header record but they don't want to change the file contents.  Any ideas would be appreciated.
    Thanks,
    Sinead.

    You could follow the following method
    1.Let the external file reside in the SAP application layer in a defined path e.g. /usr/sap/tmp/interface/working/
    2.Write an ABAP program which will include the following steps:-
       i) read all files in the file path using function module EPS_GET_DIRECTORY_LISTING
      ii) Read the data from files existing in the directory using OPEN_DATASET statement
    iii) After the files have been read move the files to another directory e.g. /usr/sap/tmp/interface/backup/ or you can delete the file.
    3.Schedule this program to be executed depending on the frequency of the external file being generated.

  • Scripting pl/sql from unix

    I am wondering if there is a way to do this with certain restrictions. If not, I can do it another way.
    1. I have a list of values in a unix .txt file of the form
    VALUEA
    VALUEB
    VALUEC
    I know how to read a list in unix using a loop.
    2. I want to call a pl/sql anonymous block that I have in a .sql file 1 time for every value in this script and pass the value.
    I do know how to read a value and then pass it to a pl/sql parameter and then call the pl/sql parameter.
    What I don't know how to do is
    Do this with only logging into sqlplus one time. I dont want to do the following
    unix runs in a loop
    reads 1 record from file
    logs into sqlplus
    runs the procedure and passes the value
    log out of sqlplus
    end loop
    I want to
    1. read all the values from the file
    2. store it somehow in memory (variable of some sort)
    3. pass this value to the pl/sql procedure
    I do not want to make any objects in the database such as a global temporary table.
    Yes I can actually do this, but wondering if it is possible to avoid. Makes it easier to deploy to alot of different databases. If I have to make a database object, then i have to make an object in alot of databases. If I can run it all from unix, all I have to do is change the target and the password. So it is easier to deploy.

    I don't need to put this in an Oracle Directory. I am not calling anything from pl/sql stored in the database. It is going to all be done with unix scripts and anonymous block sql in .sql statements in the OS. This allows me to take advantage of clustered storage (I can have alot of databases servers mounted on 1 directory). So the unix script will log into oracle and call the .sql script.
    I can build the pl/sql dynamically. I'd rather not do that. The thing is I have alot of databases I want to deploy code to. So I am trying to come up with a pattern I can follow. So if I add a new database or what to deploy somewhere else, I can just use add a line to a file.
    Adding database objects every time I need to deploy to a new database is a pain. It is far more scaleable to handle all of this in unix.
    Edited by: Guess2 on Jan 12, 2010 7:43 AM

  • Invoke the command unzip from unix in java-code ...

    Hi people,
    i have problem, i want to use the command unzip from unix, to unzip a zip-file, the commend unzip must invoke from java-code. Can someone help me. I use the zip-api, but i have 100Mb zip-file, it needs very long time to unzip the zip-file.
    thanks for your help ...

    use Runtime.exec() to call your unix "unzip" command from java, if its much faster.

  • Load XML data from UNIX Server Directly into Relational Database Tables

    Is there a way I can load data from an XML File into Oracle Tables , without having the Input XML file in some Oracle Server Directory. My XML File resides on UNIX Application server. And I need to directly load the data into Database tables. Without loading them into the Database Directory.
    Also I am looking for a solution that would not load my Database much and effect other running processes. Can it be done using SQL Loader ?
    Oracle Database Version is : Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

    Thanks for your reply ,
    Please would you quote an Example about : 'Load the file into that table using SQL*Loader'  (From UNIX Server) Or instance of some existing thread that relates to my situation.
    The Size of the File would be about 3 GB. For a similar requirement one of my peers Code which used XMLTABLE and XPATH Approach consumed a lot of resources while running and caused the other Database Applications to slow down. Thus those guys have come up with an approach to :
            Parse XML using a C Code using some STRING Functions =>  For a CSV or Fixed width .dat file and then use SQL Loader to just load the file into Tables.
            This approach is efficient in terms of Resources and Time(Takes 5 mins). But I am not confident about parsing XML based on String based C Functions.
             Please comment about this approach . Also if possible Suggest the best efficient way of doing this.

  • Retreiveing time from EIT Table

    Hello All,
    I am righting a private section parser at the Java layer using DAVIC APIs. Can somebody let me know how to convert the UTC time in milliseconds to
    local time in Java
    //epoch seconds from 1970 to 1980
    long offset=315982800
    (starttime + offset ) * 1000;
    now how do i convert to local time taking into acoount the daylight saving and zone offset

    hoek:
    Database:
    Row#     BANNER
    1     Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    2     PL/SQL Release 10.2.0.4.0 - Production
    3     CORE     10.2.0.4.0     Production
    4     TNS for Solaris: Version 10.2.0.4.0 - Production
    5     NLSRTL Version 10.2.0.4.0 - Production
    Index:
         Index Name     Unique?     Logging     Degree     Column Name     Order     Position     Index Owner
    PLAIN     USF_AS_STATUS_SLOT_MRG_PAA_IDX     N     YES     1     PERSON_UID     Asc     1     USF_STU
    PLAIN     USF_AS_STATUS_SLOT_MRG_PAA_IDX     N     YES     1     ACADEMIC_PERIOD     Asc     2     USF_STU
    PLAIN     USF_AS_STATUS_SLOT_MRG_PAA_IDX     N     YES     1     APPLICATION_NUMBER     Asc     3     USF_STU
    select * from usf_as_status_slot_merge where rownum=10;
    After 5 mins, I cancelled the above query
    I clicked on Explain plan and it showed:
    SELECT STATEMENT FIRST_ROWS
    Cost: 10,513 Bytes: 434,488,026 Cardinality: 1,493,086
    C(*)Count
    Table Access Full Table USF_STU.USF_AS_STATUS_SLOT_MERGEDon't know about trace/tkprof
    Don't know about skewed data

  • Time From field is not getting displayed in correct format in Activities

    Hello Experts ,
    We are facing one problem in UI , when we search for Activities in Web UI . In the field "Time From" we are not getting the time in correct format , ie is instead of  getting time as say 13::38 we are getting time as 13::3 , but when we place cursor on it the field it shows correct format say 13::38.
    Can any one suggest how to display in correct format ?
    Regards
    Vinayak

    Hi,
    Its an SAP Product error.
    Please check note 1151821 ,if you facing the greyed button in time.Also the other note 1136402 needs to be applied for time display issue
    - Bobby

  • View more than one sheet at a time from the same file?

    I'm trying to view two different sheets at the same time from one file. This was possible in excel by opening a "new" window. Does anyone know how to do this in numbers?
    Thanks for the help,

    Skigilboa wrote:
    I'm trying to view two different sheets at the same time from one file. This was possible in excel by opening a "new" window. Does anyone know how to do this in numbers?
    You know what: Happily, _*Numbers is definitively not a clone of Excel*_ !
    It's not forced to duplicate every features of this program !
    We may see every tables of a given sheet
    but we can't see tables of two sheets simultaneously.
    This feature is very important because it's linked to
    the one which allow us to have different orientation for different sheets.
    Yvan KOENIG (VALLAURIS, France) dimanche 13 septembre 2009 15:04:06

Maybe you are looking for

  • Issue with CALL SELECTION-SCREEN

    Hi experts, I am working on a report. Here on the selection screen , based on the selection of some radiobuttons ,i want to call a secondary selection screen. So i am using the following program code , AT SELECTION-SCREEN on BLOCk blk. IF p_abc  =  c

  • Latest nightly build SDK_4.1.0.14651 error

    I downloaded the latest nightly build of gumbo SDK (flex_sdk_4.1.0.14651) and installed it on my flash builder 4 beta 2, but when I run each of my project, I see these run-time errors: Error #1014: Class spark.skins::SparkSkin could not be found. Err

  • "hi i forgot my security questions ansewers plesas help how recover man answers "

    "hi i forgot my security questions ansewers plesas help how recover man answers

  • Ethernet sniffer with FPGA

    Does anyone have code to receive Ethernet trames with FPGA decoder?  (like the code on DevZone which includes code for reading and writing RS-232 data.) I would like to build a fast Ethernet sniffer and data decoder Any FPGA code or idea would be app

  • KWin compositing only in XRender mode / unable to use OpenGL mode.

    Hi, somehow I am unable to activate kwin4 compositing in OpenGL mode. If I try to I get the following message: "Failed to activate desktop effects using the given configuration options. Settings will be reverted to their previous values. Check your X