System.currentTimeMillis() and Date()

Hi,everybody
What is the difference beetween System.currentTimeMillis() and Date()?
Regards,
Michael

Michael,
System.currentTimeMillis()  -- current date represented as number of milliseconds after/before Jan 1, 1970
java.util.Date -- object that encapsulates date, when constructor called without arguments then it's current date. Note that almost all methods of this class are deprecated while it was designed only for Grigorian calendar. To get specific day/month/year from java.util.Date use java.util.Calendar.
Valery Silaev
SaM Solutions
http://www.sam-solutions.net

Similar Messages

  • How to get system time and date with PHP

    Dear Mr.Craig,
      Thanx a lot. We are running SRM 5.0 (RAMP - Implementation).
      My initial requirement is to write a server-side script to display server date and time. Could you give more inside on how to achieve it?
    Regards,
    Deva.

    Perhaps that will help.
    [code]
    <html>
    <h1>Access System time and date</h1>
    <?
         // saprfc-class-library     
         require_once("saprfc.php");
         $sap = new saprfc(array(
       "logindata"=>array(
       "ASHOST"=>"localhost"          // application server
       ,"SYSNR"=>"00"                    // system number
          ,"CLIENT"=>"000"               // client
          ,"USER"=>"bcuser"               // user
          ,"PASSWD"=>"minisap"          // password
         ,"show_errors"=>false               // let class printout errors
         ,"debug"=>false)) ;                     // detailed debugging information
         $result=$sap->callFunction("MSS_GET_SY_DATE_TIME",
            array(     array("EXPORT","SAPTIME",array()),
               array("EXPORT","SAPDATE",array())));
         if ($sap->getStatus() == SAPRFC_OK) {
        echo "Time: ".$result["SAPTIME"];
        echo "<br>Date: ".$result["SAPDATE"];
        echo "<br>or<br>";
        echo "Server is showing: "
             .substr($result["SAPDATE"], 0, 4)
             ."-".substr($result["SAPDATE"], 4, 2)
             ."-".substr($result["SAPDATE"], 6, 2)
             ." and "
             .substr($result["SAPTIME"], 0, 2)
             .":".substr($result["SAPTIME"], 2, 2)
             .":".substr($result["SAPTIME"], 4, 2);
         } else {
              $sap->printStatus();
         $sap->logoff();
    ?>
    [/code]

  • Error when giving untill condition for System time and date

    Hi Experts,
    i am using Untill Loop in my workflow to set condition for System time and date.According to this condition when system date and time is greater than equal to some date and time then mail goes to an agent.But during testing , the workflow gets into error stage.
                 In workflow log i am getting error like
    'Maximum number of    10000 nodes reached' in executed action 'DEQUEUE_NEXT_NODE'  for false condition.
                        Please suggest what may be possible cause or solution for it?
               Points will be rewarded for any good solution.
    Thanks
    Snehasish Das

    Hi,
    You should not use loop for that kind of purpose. It sounds to me that your workflow is looping all  the time, and the maximum numer of nodes is reached soon, and the workflow goes into error.
    You should use the WF deadline functionality for your purpose. For example use in a relevant step the "latest end" tab, and define the deadline there. Then when your deadline is reached, the workflow will continue in a separate outcome, and there you can send your mail.
    Regards,
    Karri

  • How to get System Time and Date?

    Hi, may i know how do i get the System's current Time and Date?? And i need to format them into 2 separate String, that's Time is a String, Date is another String. Pls guide me. Thanks a lot!

    What's the problem? The previous example was pretty clear. Just adapt it to your purposes...
            Date currentDateAndTime = new Date();
            SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
            SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
            System.out.println(dateFormat.format(currentDateAndTime));
            System.out.println(timeFormat.format(currentDateAndTime));

  • How to show two different plots with current system time and date on waveform chart

    I am using  one waveform chart to display the more than one value continiously. The data  are comming properly but i am not getting my system (pc) time and date on x axis. It is showing default date and time (i.e.01/01/1904 5:30:45). Please  give me suggestions to display the real time and date on x axis of waveform chart. 

    How does your data look like? Do you graph waveform data types, dynamic data, or plain arrays/clustes? In the case of plain arrays, you need to set x0 to the absolute start time of your data, e.g. with a property node.
    I you would attach your code (or an image) we could offer more specific advice. There are too many possibilities.
    LabVIEW Champion . Do more with less code and in less time .

  • Hi add fields in ztable user name system time and date urgent

    i have to add three new fields in my z table
    a)user name
    b)system time
    c)date
    suppose if anyone update my ztable then the above three fields should catch the values as which user change the ztable at what time and on which date
    plzzzzzz help
    urgent
    saurabh

    To create the fields use the following field types.
    CPUTD - for Date
    CPUTM - for Time
    USNAM - User name.
    when updating the table pass the system variable.
    sy-datum - for date
    sy-uzeit - for time
    sy-uname - for user name

  • Capturing system time and date and the time difference and date difference.

    Hello Experts,
    i have a requirement the i need to capture select query start time and date as i runthe program on midnight (ie) 11:55 p.m.
    I tried system fields sy-datum and sy-uzeit for capturing the system date and time when my program runs but it gets reset when the date changes.
    i tried get time field option but it is resetting the sy-datum to zero so i am able to capture the date of the next day and resulting in wrong calculation of time .
    please help with your valuable answers.
    Thank you,
    Srinivas.

    Hi,
    As per my understanding you want to fetch those data which are created between the program last run date time and current date time.
    If I am right please follow the below procedure.
    1. Create one custom table to store program name and program execution last date time
    2. at event INITIALIZATION populate to fields date and Time using the statement sy-datum
    initialization.
      v_curr_time = sy-uzeit.           " Current time
      v_curr_date = sy-datum.           " Current date
    3. Get the last run date and time from the above custom table.
    4. Do your logic.
    5. at last Update the custom table with current date and time based on the step two (Here do not take sy-datum like that, take the value in the global variable populated in step 2)
    Thanks
    Subhankar

  • Timers! System.currentTimeMillis() and Thread.Sleep = ?????

    I've experienced some strange results using timers etc. Can anyone explain this:
    package TestPackage;
    public class Timer {
        public static void main( String args[] ) {
            new Timer();
        /** Creates a new instance of Timer */
        public Timer() {
            while ( true ) {
                long startTime = System.currentTimeMillis();
                try {
                    Thread.sleep(100);
                } catch ( Exception e ) {
                    System.err.println("Trouble sleeping tonight...");
                System.out.println("RunTime=" + (System.currentTimeMillis() - startTime) );
    Output:
    RunTime=109
    RunTime=94
    RunTime=109
    RunTime=94
    RunTime=93
    RunTime=110
    RunTime=94
    How can the run time be less than the sleep time ?!?!?!
    Cheers,
    Rob

    There are a multitude of problems here and all of them are Windows related.
    1) Any difference under 10 milliseconds is purely speculative on the part of the OS
    2) There is a Windows bug whereby calling some Windows API with regards to system time basically causes Windows to fall ill with a concussion, temporary coma followed by confusion. The most common symptom of this particular bug is that repeated calls to this API cause teh system clock to accelerate but the nature of the bug means that a variety of tests and results such as this one may be thrown into confusion.

  • System.currentTimeMillis() and GMT

    Before someone says read the api. I have. But this point is not clear.
    Is System.currentTimeMillis() in GMT?
    Why do these two methods return the same result? (by the way I am not in HongKong).
    Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("Hongkong"));
    System.out.println("HONGKONG In MILIS" + cal.getTimeInMillis());
    System.out.println("LOCAL In milis "+ System.currentTimeMillis());
    thanks

    yup that makes it clear. Thanks.
    I got another related quickie though:
       System.out.println("LOCAL In milis    " + System.currentTimeMillis());
        String[] avails = TimeZone.getAvailableIDs();
        for (int i = 0; i < args.length; i++)
          System.out.println(avails);
    Calendar cal = new GregorianCalendar(TimeZone.getTimeZone(avails[i]));
    System.out.println(avails[i] + " In MILIS " + cal.getTimeInMillis());
    This loop is never firing, why are no ids available?

  • Can't lock changes in System Preferences and Date & Time goes crazy

    For some reason the items I lock in the System Preferences window become unlocked by itself. I have the password protect on, but it completey ignores it and unlocks the locks at a random time. This happens most frequently with my Time Machine prefs.
    Also my Date & Time changes to whatever time it wants automatically. I have this password locked as well, but the computer seems to have a mind of its own.
    Any ideas?
    Thanks in advance.

    Boot with your install disk, launch Disk Utility, select the boot volume, and repair it. Boot back into the boot volume and try again. If you get the same behavior, move the com.apple.systempreferences.plist file to the desktop, log out and back in, and try again. If still no go, try a safe boot and see if it work s properly.

  • Export File name as system time and date

    Dear all
    Please kindly help me to get the solution
    I want to mark my dunp file as system date and time.
    thanks adv
    Ora-BD

    Hi..
    Refer to below link, it might be helpfull
    Export dump file and log file  name as sysdate in script
    Anand

  • Timer problems on Linux changing system time and data

    On Linux SO,
    both with flash player plugin and standalone flash player, setting system time with command:
    date -s 11:11:11
    hang timers (flash.utils.Timer) immediately!

    I notice that updating system time (both with "date -s hh:mm:ss" and through ntpd) with a new time in the future doesn't hang up flash.utils.Timer component.
    Contrary, if I update system time with a past new one, flash.utils.Timer stops work immediately!!!
    This is huge problem for those interfaces that need to run for a long time and also need to be time updated (for examplem through ntp daemon).
    Can anyone help me?
    PS: Windows Flashplayer doesn't have this problem !!

  • Difference between using new Date() and new Date(System.currentTimeMillis()

    Hi All,
    I have seen many open source api's where they are updating dates with the following code
    new Date(System.currentTimeMillis())
    when i print the new Date() it prints the same
    what is the difference between using new Date() and new Date(System.currentTimeMillis()) ??
    Thanks,
    J.Kathir

    when i print the new Date() it prints the same
    It does because of backward compatability. This constructor exists in version 1.3.1 but not in newer versions.Really ? Please point me to where you read that.
    API doc 1.5 : new Date() (still there, not even deprecated)
    A quick look at the code for this constructor:    /**
         * Allocates a <code>Date</code> object and initializes it so that
         * it represents the time at which it was allocated, measured to the
         * nearest millisecond.
         * @see     java.lang.System#currentTimeMillis()
        public Date() {
            this(System.currentTimeMillis());
        }

  • Nokia 6030 and System.currentTimeMillis

    Hi
    I'm developing my game for J2ME phones. It works well on a lot of devices. Today I got Nokia 6030 (S40 2nd Edition) and tested my game on this phone. It very strange! Timer works veeeery fast. I made small debug on screen. I made drawString System.currentTimeMillis() and I saw that time goes very fast. On all phones System.currentTimeMillis() increases 1000 per second. On 6030 System.currentTimeMillis() increases 1000000 (or more) per second. Why?!?! On emulator of Nokia 6030 it works well (1000 per second). It very strange. I tested this program on a lot of devices and everywhere it worked well.
    Help me, please...
    MDW

    could be a bug, someone accidentally putting tree zero to much in their code...

  • Function module to display the time and date in the report-sy-udate And s

    Hi.
    wish to have a function module which can display the system time and date through function module.
    the format that this function module should display should be like this:
    if its today-date and time then:
    05-Jan-08 01.25.57 PM
    please note that i want them to be in one single row in the top-of page
    kinldy help on this.
    thanks!

    hi,
    check this.
    https://forums.sdn.sap.com/click.jspa?searchID=19175181&messageID=4628668
    Thanks

Maybe you are looking for

  • Getting channel units and length from .dbc file

    Can any one help me out. I was wondering how to get Channel units and channel size from the CAN db file similarly like getting channel names from Get Channel Names by Id vi. Thank you, Shanth.

  • Satrtup.batch file in SUM

    Hello, I have to run sum tool for that I am running startup.bat file but it opens and disappears. Please guide me. Thanks and Regards, Akshay

  • Problem: Changing print quality iMac + Canon Printer MG6220

    If I want to print a web page in Firefox from my iMac to a Canon MG6220 printer, I cannot change the print quality. I can only choose "Standard" and not "Fast". All other options for print quality are "grayed-out". This happens in both Firefox and Au

  • Daq assist question

    Im using the DAQ assist to look at counting input on my dev1 ctr3 line that goes to my counter/timer board. Initially I was using edge count in a 10ms timed loop to count pulses. But I ran into some counting variations (i suppose this is because i am

  • Selective disable/enablement of sub workflows

    Hi, I am trying to design workflow with fork(For parallel execution) and many sub workflows. These sub workflows are totally independent of each other and cna have parallel execution. My requirement is to given an option for user to selectively enabl