Does System.currentTimeMillis() always return correct time?

Can i rely on it for performance testing?

It gets the time from the computer the application is running on. I can think of at least three things that will change this time:
1. A user (or another program) changes the time.
2. Your operating system changes the time automatically when daylight savings time starts or ends.
3. NTP (Network Time Protocol) is running on your computer and adjusts the time to match the time on some other computer;.

Similar Messages

  • Always return GMT Time Zone in Bundle Image Deployment

    I have application that need to get window PC time zone, when use Bundle Image Deployment (include runtime jre), it always return GMT time zone no matter which time zone I set on my PC. After I replace runtime/jre in the image folder with complete jre, then it returns time zone correctly. Is it a bug in bundle deployment?
    javafx.runtime.version: 2.2.7-b01
    jdk1.7.0_17
    window 8 64bit
    Thanks.
    Eric

    I am experiencing similar type of issue.  I subscribed to a Calendar which has scheduled meeting from my time zone and different time zone.  When I subscribe in OS X, it shows flawlessly on local time. But when I do it in IOS 7,  it shows MST as-is in EST time zone and no matter we play around all the time zone setting in General tab or Mail/Calendar tab.  It's not helping.
    Appears to be a bug in IOS 7.  It needs to be reported to Apple.

  • Does System.currentTimeMillis() cater for daylight saving

    My question is does System.currentTimeMillis by any means cater for the daylight savings time or in the other case when clocks are moved backwards it repeats it self???????
    Its pretty confusing isnt it?

    the whole problems with the currentTimeMillis is that it calculates the offset from the System clock - System TimeZone Offset
    if the System uses Manual DST or the auto DST is not checked (Windows)
    The the user of the system changes manually the clock and the calculation
    current millis will be wrong one hour
    for example I am in GMT + 2 + DST(1)
    GMT is 1200
    Local OS shows 1400, and I manually change it to 1500 (DST check box is not checked
    the Java will report GMT time 1300 (1500 - 2:00)
    whic is wrong.
    There is no indication wether this check box is checked or not
    If anyone knows how to find out if its checked please tell all

  • Simple script unable to return correct time

    I have set up a timer that dispatches an event after the milliseconds have been calculated, however it does not work to my liking
    var date:Date = new Date();
    //Timer set at what time would i like to call the function
    var lastcallH:Number = 23;
    var lastcallM:Number = 51;
    var lastcallS:Number = 0;
    //Set up the 24 hour clock
    var tHour:Number = 24;
    var tMinute:Number = 60;
    var tSecond:Number = 60;
    //Getting the current Time
    var cHour:Number = date.getHours();
    var cMinutes:Number = date.getMinutes();
    var cSeconds:Number = date.getSeconds();
    //Define the First variable
    var fH:Number;
    var fM:Number;
    var fS:Number;
    //Define a Second Set of Variable
    var sH:Number;
    var sM:Number;
    var sS:Number;
    //Final conversion for the Timer
    var finalMil:Number;
    //Time variables which will have to be converted
    if (cMinutes > 0 || cSeconds > 0) {
    ++cHour;
    ++cMinutes;
    fH = cHour - tHour;
    fM = cMinutes - tMinute;
    fS = cSeconds - tSecond;
    else {
    fH = cHour - tHour;
    fM = cMinutes - tMinute;
    fS = cSeconds - tSecond;
    sH = fH + lastcallH;
    sM = fM + lastcallM;
    sS = fS + lastcallM;
    if (sH < 0 || sM < 0 || sS < 0)
    sH = sH * (-1);
    sM = sM * (-1);
    sS = sS * (-1);
    finalMil = (sH * 60) + (sM * 60) + (sM * 60);
    //Lets set up a timer
    var yahooTime:Timer = new Timer(finalMil, repeat);
    var repeat:Number = 1;
    yahooTime.start();
    yahooTime.addEventListener(TimerEvent.TIMER, displayLastCall);
    function displayLastCall(event:Timer):void
        trace("Well we go sucess");
    Getting such error:
    TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::TimerEvent@e173d91 to flash.utils.Timer.
        at flash.utils::Timer/_timerDispatch()
        at flash.utils::Timer/tick()
    Any suggestions

    You can not catch any event as some other object focus on the signature of the following function
    function displayLastCall(event:Timer):void //Incorrect conversion of an event to Timer class
        trace("Well we go sucess");
    Now take a look at the correct declaration of this function
    function displayLastCall(event:TimerEvent):void //Correct catch as the TimerEvent
        trace("Well we go sucess");

  • Does iCal report always report .ics times as GMT when sending via Mail?

    I received a .ics file from someone sending it in Outlook in Los Angeles (GMT-08:00) for an event from noon to 2pm. I am in the same time zone. I double-clicked it, and it showed up as a tentative event in iCal, starting at noon as expected. I then accepted it, and an email was automatically sent to the other participants. In the body text, it said: "Rehearsal, scheduled for December 7, 2008 at 8:00 PM (GMT)."
    The recipient didn't pay attention to the "GMT" text. Is the body text always going to report in GMT, or are there other other options?
    I haven't thought through all the ramifications, but it would be useful to report the local time (of the person(s) receiving the confirmation email(s).
    Relevant parts of .ics file I received:
    DTSTART:20081207T200000Z
    DTEND:20081207T220000Z
    DESCRIPTION:When: Sunday\, December 07\, 2008 12:00 PM-2:00 PM (GMT-08:00)
    Pacific Time (US & Canada).
    Relevant parts of .ics file sent from my machine automatically upon acceptance in iCal:
    CALSCALE:GREGORIAN
    DTSTART:20081207T200000Z
    DESCRIPTION:When: Sunday\, December 07\, 2008 12:00 PM-2:00 PM (GMT-08:0
    0) Pacific Time (US & Canada).
    DTEND:20081207T220000Z

    I'm a few steps further towards a working iCal server now. Your answer clarified a lot.
    User on iCal server:
    Invitations are sent via [email protected] Both to invitees on same email domain and to external invitees.
    When I (user on iCal server) am invited by someone not on our iCal server, I get the invitation via Mail.app and iCal local reads it. And I'm able to reply, and my reply status updates in my local iCal. No problems so far.
    Mail.app (not iCal server) then sends a reply. And the inviter receives the reply as an email which is an .ics file attached. But the .ics is not understood by users not on iCal server.
    The format looks like this:
    ATTENDEE;CN="Myfirstname Mylastname";
    CUTYPE=INDIVIDUAL;EMAIL="[email protected]";
    PARTSTAT=ACCEPTED;
    ROLE=REQ-PARTICIPANT:urn:uuid:38BCCE7F-D85C-4C17-872E-5C3CFFFB4838
    I looks like the inviters iCal is not able to translate urn:uuid:38BCCE7F-D85C-4C17-872E-5C3CFFFB4838 to anything usable. And therefore sees it as if an unknow user has replied to the invitation. Apparently neither Mozilla Lightning og iCal local looks at EMAIL="[email protected]";
    Inviting and replying to and from users on iCal server works fine.
    Do I have to map the urn:uuid to the email somehow? Where? Or somehow allow external inviters to look to our server for urn:uuid to email translation?
    Or can I manually change a config file to send an .ics with my email insted my urn:uuid? Like this:
    PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPANT:[email protected]

  • System.currenttimemillis() returns value ..can't decode it

    Does System.currenttimemillis() return milli seconds elapsed after Jan 1, 1970... does it have no relation with our current time...
    When i did it and print it out .. my millis were the last 3 digits and secs were the 2 dgits before miiliseconds..
    eg: XXXXXXXssmmm
    or was it just a mere coincidence...very confused..

    I was always taught to use Calendar to access individual fields (and DateFormats for formatting and parsings). One reason you aren't supposed to just take the timestamp value (System.currentTimeMillis()) is that there are complications: for example, because of Earth's wobbly orbit there are things called "leap seconds" that may be added to years, so you can't assume each day consists of exactly 24*60*60 seconds (even ignoring DST). But then I wrote this code:
    import java.text.*;
    import java.util.*;
    public class Currently {
        public static void main(String[] args) {
            long now = System.currentTimeMillis();
            Date date = new Date(now);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z");
            TimeZone tz = TimeZone.getTimeZone("GMT");
            sdf.setTimeZone(tz);
            String output = sdf.format(date);
            System.out.format("%d --> %s%n", now, output);
            long millis = now % 1000;
            now /= 1000;
            long seconds = now % 60;
            now /= 60;
            long minutes = now % 60;
            now /= 60;
            long hours = now % 24;
            System.out.format("Directly from timestamp %02d:%02d:%02d.%03d%n", hours, minutes, seconds, millis);
    }I'm not suggesting one abandon Calendar and DateFormat, but where are the leap seconds since 1970?

  • JDKs in weblogic server return wrong time zone

    Hi , i am running weblogic server 8.1.4, 8.1.6 and 10 on my windows vista
    all of the JDK bundled (both Sun's and JRockit) return GMT instead of my local time zone when i call Timezone.getDefault()
    I am quite sure the operating system has set to correct time zone because my self installed JDK (downloaded from sun) works properly (return correct local time zone)
    is that i have missed anything?
    please help.

    I am noticing the same problem with iCal events imported from Orbitz. The thing is that the more I look into it the more I think this is meant as a feature, not a bug. Go into iCal preferences > Advanced and uncheck "Turn on time zone support". Import the event again and this time both the graphic view and the Get Info view will display the same information.
    It appears that this setting is meant to be useful if you travel to different time zones a lot. Basically, with it you get a time zone dropdown menu in iCal. So when you are in a different time zone you can select it from the dropdown and it will show what time your events occur in your new local time. Just keep in mind that when you create a new event it will be created based on the time zone you have selected. So if you are in California and have selected that time zone but you are adding an entry for a meeting you have when you are back in New York make sure that you select the correct time zone when creating that meeting because by default it will be created in California time and when you return to New York and switch your calendar back it will show the event at the wrong time.
    Frank

  • System.currentTimeMillis() not respecting system clock

    How does System.currentTimeMillis() work? I thought it checked the system clock. But I have an application that monitors the clock and I try to catch changes in it (for instance if the user changes his/her clock during runtime). But the System.currentTimeMillis() seems to ignore the time changes of the sytem clock. Any ideas?

    I had already done that. That is why I posted. I
    could have sworn it worked from previous experience,
    but I am not seeing it work now...The following code:import java.io.*;
    import java.util.*;
    public class TimeDemo {
        public static void main(String[] args) {
            try {
                InputStreamReader isr = new InputStreamReader(System.in);
                BufferedReader br = new BufferedReader(isr);
                System.out.println(System.currentTimeMillis());
                br.readLine();
                System.out.println(System.currentTimeMillis());
            catch (Exception e) {
                System.out.println(e);
    }Produces the following output:
    $ java TimeDemo
    1120149951371
    1117644363468 You'll note that time appears to have gone backwards - but in fact I set the clock back during the readLine block. So I think it does respond to changing the clock (at least under Solaris on a SPARC with Java 1.5).

  • News feed on my Facebook app doesn't show the correct time. Can the time be set?

    News feed on my Facebook app doesn't show the correct time.  Can the time be set?

    Does your phone show the correct time?
    If not, change the time on your phone, see if it helps.
    If it does, then sign out, sign back in. If that fails, the delete and reinstall. If that fails, then contact Facebook, as they're the developers of the app and will have the proper documentation to help you further.

  • System.currentTimeMillis() returns time in UTC or not??????

    Hello Friends,
    I want to know that "System.currentTimeMillis()" returns time in UTC or Current Local time
    ie suppose i set my TimeZone (GMT+ 2)
    then statement gives me value in milliseconds by adding 2 hours to the GMT(Is this value should consider as UTC time or we have to subtract and add offset value according to the timezone.
    If time value return by statement is in local time and this is not UTC then is there is any provision in Java to convert local time into UTC time ??
    Regards
    Gaurav

    ejp wrote:
    It returns 'the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.'.Which, of course, as I have tried to explain to the OP (but seemingly not very well) that the "current time" referenced must also be the "current time" in UTC. If the starting point is UTC the ending point is UTC (otherwise it doesn't make any sense to measure it that way). I also attempted to tell him that, when he outputs a String representation of that time (i.e. toString or with a DateFormat Object) that the time he sees will be the time according to the TimeZone set in the DateFormat object, or the local timezone when using toString. But, as mentioned, Date objects (and so, essentially, the long value) is always UTC (relevant to the starting point, of course).
    A quote from the Date Class
    Although the Date class is intended to reflect coordinated universal time (UTC), it may not do so exactly, depending on the host environment of the Java Virtual Machine.which I take to mean that Date is always UTC in so far as the host environment is capable of it.

  • Good morning, I returned a few days abroad (Antigua), 4 my iphone does not come back to the correct time of Rome in automatic mode but only manually, there is a solution to restore the correct time in automatic mode? ? Thank you.

    Good morning, I returned a few days abroad (Antigua), 4 my iphonedoes not come back to the correct time of Rome in automatic modebut only manually, there is a solution to restore the correct time in automatic mode? ?
    Thank you.

    Hi,
    Try a Reset of the Phone... You will Not Lose Any Data...
    Turn the Phone Off... ( if it isn’t already )
    Press and Hold the Sleep/Wake Button and the Home Button at the Same Time...
    The Apple logo will Appear and then Disappear...
    Usually takes about 15 - 20 Seconds...
    Release the Buttons...
    Turn the Phone On...
    iPhone User Guide
    http://manuals.info.apple.com/en_US/iphone_user_guide.pdf

  • System.capabilities.language always returns en on OS X Leopard

    Hello everyone!
    I am having some trouble with the Flash (ActionScript 2.0) on
    an Intel MAC running OS X Leopard. It seems that no matter how i
    change the OS language (via System Preferences or at installation)
    the System.capabilies.language call always returns "en". More
    bothering is that apparently, on non-intel macs running Leopard,
    some languages are detected and shown correctly (German and
    Italian)...
    I looked al over the Internet for a hint but i could not find
    any. So ... please help... is this an OS problem, a Flash problem
    or do i need a "native french" (or any other language) Leopard
    installation disk ?
    Thanks!

    Hello,
    Here's information for Resolving Kernel Panics
    You've done a great job so far of trouble shooting...
    -did the apple hardware test
    -tested the RAM for any defects
    -recently did an ARCHIVE and INSTALL
    Before you go to the link above, have you tried checked the boot disk for errors? If not..;.
    Restart your Mac while holding down the C key, pressing the power button and inserting your restore disk all at the same time. An Installer window will open, but do not proceed with any installations. Instead, from the Menu Bar, select Utilities > Disk Utility. In the Disk Utility window click First Aid, and then click Verify. If Disk Utility reports errors, click Repair. When Disk Utility is finished, from the Menu Bar, select Utilities/Startup Disk. Select MacintoshHD 10.x.x and click Restart.
    Try disconnecting any peripherals, iPod's, mice, keyboards, cameras....
    (I know you have a MacBook, but many people use the peripherals anyway).
    Reboot and see if that makes a difference.
    Get Leopard Cache Cleaner available here:
    http://www.apple.com/downloads/macosx/systemdiskutilities/leopardcachecleaner.html
    "Leopard Cache Cleaner lets you create bootable Emergency Disks that include system repair utilities and LCC’s powerful cache cleaning functions. If disaster strikes, the power of Leopard Cache Cleaner is available at the command prompt in Single User Mode"
    If none of the above help, then go to the link above for kernel panics.
    Carolyn

  • Why does getdate() function return same time value for multiple select statements executed sequentially

    When I run the following code
    set nocount on
    declare @i table(id int identity(1,1) primary key, sDate datetime)
    while((select count(*) from @i)<10000)
    begin
    insert into @i(sDate) select getdate()
    end
    select top 5 sDate, count(id) selectCalls
    from @i
    group by sDate
    order by count(id) desc
    I get the following results. 
    sDate                   selectCalls
    2014-07-30 14:50:27.510 406
    2014-07-30 14:50:27.527 274
    2014-07-30 14:50:27.540 219
    2014-07-30 14:50:27.557 195
    2014-07-30 14:50:27.573 170
    As you can see the select getdate() function returned same time up to the milisecon 406 time for the first date value.  This started happening when we moved our applications to a faster server with four processors.  Is this correct or am I
    going crazy?
    Please let me know
    Bilal

    Observe that adding 2 ms is accurate only with datetime2.  As noted above, datetime does not have ms resolution:
    set nocount on
    declare @d datetime, @i int, @d2 datetime2
    select @d = getdate(), @i = 0, @d2 = sysdatetime()
    while(@i<10)
    begin
    select @d2, @d, current_timestamp, getdate(), sysdatetime()
    select @d = dateadd(ms,2,@d), @i = @i+1, @d2=dateadd(ms,2,@d2)
    end
    2014-08-09 08:36:11.1700395 2014-08-09 08:36:11.170 2014-08-09 08:36:11.170 2014-08-09 08:36:11.170 2014-08-09 08:36:11.1700395
    2014-08-09 08:36:11.1720395 2014-08-09 08:36:11.173 2014-08-09 08:36:11.170 2014-08-09 08:36:11.170 2014-08-09 08:36:11.1700395
    2014-08-09 08:36:11.1740395 2014-08-09 08:36:11.177 2014-08-09 08:36:11.170 2014-08-09 08:36:11.170 2014-08-09 08:36:11.1700395
    2014-08-09 08:36:11.1760395 2014-08-09 08:36:11.180 2014-08-09 08:36:11.170 2014-08-09 08:36:11.170 2014-08-09 08:36:11.1700395
    2014-08-09 08:36:11.1780395 2014-08-09 08:36:11.183 2014-08-09 08:36:11.170 2014-08-09 08:36:11.170 2014-08-09 08:36:11.1700395
    2014-08-09 08:36:11.1800395 2014-08-09 08:36:11.187 2014-08-09 08:36:11.170 2014-08-09 08:36:11.170 2014-08-09 08:36:11.1700395
    DATE/TIME functions:
    http://www.sqlusa.com/bestpractices/datetimeconversion/
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Java always returns 15 minutes greater than the current time.

    Hi,
    I am using Microsoft Windows Server 2003R2,Standard X64 edition with Service Pack 2 and jdk1.6.0-03.
    Java always returns time 15 minutes greater than the current system time.
    eg:
    SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    System.out.println("Now time: "+simpleDateFormat.format(new Date()));
    System.out.println("Now time: "+new Date());The output of the program is :
    Now time: 2008-12-22 18:47:04
    Now time: Mon Dec 22 18:47:04 NPT 2008
    When my actual system time is 6:32 PM or (18:32)
    I have checked the current time with other programming languages like python and it always returns the actual date and time.
    Note: To my observation java is always utilizing a time which is 15 minutes greater than the current time even for its log.
    Thanks,
    Rajeswari (Msys)

    I think a more practical time machine would be one that actually travels back in time rather than forward (by 15 minutes). Sounds like it needs some more work.
    Anyway, I suggest changing the system time on your computer to some other value (say, 2 hours ahead), then running the program again. If its off by 2 hours and 15 minutes, its getting the time from your computer. However, if its still off by only 15 minutes (from your wristwatch's time), then its getting the time form somehere other than the computer clock.

  • MessageChoice does not return correct value

    Hi
    I am problem with MessgeChoiceBean's improver beharior
    For the first time it retunrs blank and subsequently In one page if I select Yes, it returns No.
    In another page it does not return any thing for the first two selections. And I reciev flip values.
    I ran VO outside, VO is returning correct values.
    MessageChoice attributes and associated PPR:
    Data Type: Varchar2
    Initial Value: N
    Pick List view Definition: oracle.apps.xxx.docs.common.lov.server.YesNoVO
    Pick List View Instance: YesNoVO3
    Pick List Display Attribute: Meaning
    Pick List Value AttributeL LookupCode
    ActionType: firePartialAction
    Event: handleNewLocationFlagChange
    Parameter Name: newLocationFlag
    Parameter Value: ${oa.CustomerInfoVO1.NewShipToLocationFlag}
    ProcessParameterForm Code:
    if ("handleNewLocationFlagChange".equals(event))
    String newLocationFlag = pageContext.getParameter("newLocationFlag");
    Serializable[] parameters = { ""+newLocationFlag};
    Class[] paramTypes = { String.class};
    am.invokeMethod("handleNewLocationFlagChange", parameters, paramTypes);
    VO definition:
    select LOOKUP_CODE,MEANING
    FROM ONLINE_DOCS_LOOKUPS
    WHERE ONLINE_DOCUMENT_CODE = 'ALL'
    AND LOOKUP_TYPE = 'YESNO'
    ORDER BY ATTRIBUTE1
    View output:
    LOOKUP_CODE     MEANING
    N     No
    Y     Yes
    I have quite a bit number of columns to change render property.
    Any help will be appreciated.
    Thanks
    Prasad

    Your question is not clear, are you saying the values in the messageChoiceBean is not displayed properly. As far as I can see from the definition the poplist picks the values from a lookup(Yes, No) values and has a PPR action associated with it. Did you check what this method handleNewLocationFlagChange is doing in the AM ?

Maybe you are looking for

  • Purchase order user exit

    Hello Firends, I am unable to find suitable user exit. My requirement is whenever a new PO is created from Preq,the system should check a Z table where certain material/Sloc combinations are allowed. If combination is not maintained in z table, error

  • Using Discoverer in Oracle8i standard edition

    I wonder if it's ok to use Discoverer4i against Oracle8i DB (standard edition).

  • Write Spreadsheet to String Array on another worksheet

    hi, is it possible to write spreadsheet to string array but to an added worksheet? I am currently writing results to the worksheet, but i want to create another worksheet so that i can put the raw data in. is it possible? if so, how? Best regards, Kr

  • Screen has vertical lines

    hi i have IMAC 17" INTEL DUO 1.83GHZ AND SCREEN HAS VERTICAL LINES WHAT MODEL OF SCREEN I USED MY EMC # 2104 THX

  • Directory browsing and multiple upload (not AIR)

    Hello everybody! Do somebody knows is it possible to select directory and upload all files from this directory to server (not AIR)? Thanx