Q: How to get local time in milliseconds?

Hi,
As we know, Labview a G function which can get local date/time in
seconds. Is there any way to get local date/time in milliseconds? Or it
also helps if you know there is any similiar function in C/C++.
Thanks!
G. Chen
Ph.D. Candidate
Ohio Univeristy, Athens, OH
Nothing can dim the light which shines from within.
Sent via Deja.com http://www.deja.com/
Before you buy.

> As we know, Labview a G function which can get local date/time in
> seconds. Is there any way to get local date/time in milliseconds? Or it
> also helps if you know there is any similiar function in C/C++.
>
The local time function returns a double precision number.
Depending on the platform you are using, the number returned
may have a subsecond amount. This means that you subtract
and multiply by 1000 to get ms. The platform that returns
this is Win32, and its resolution is 55ms. Other platforms
will always return 0.
It is also sort of possible to synch the ms function with
the local time function, but this is not very accurate.
It involves watching the local time function in a loop
until it changes, and also sample the ms clock to synchronize
the two clocks.
From that point on, you can use the ms
function exclusively, and do the math to get back to local
time. The problem with this is that the fast clock rolls over
about every 40 days, the clock may have some drift with the
local clock, and then there is daylight saving time and time
zone math, which is always surprisingly complex.
Greg McKaskle

Similar Messages

  • How to get Locale from Character.UnicodeBlock

    Hi All,
    For Ex: I enter Japanese language (Hiragana/KATAKANA characters) in the text field. My expected result is Locale: 'ja' (this is belongs to Japaneses language)
    How to get locale value from Character.UnicodeBlock.
    or we have any other way to get locale value from "input locale" means what ever language( Japanese /Chinese/other languages supported by java) i enter in the text box and i want to identify the locale of the text.
    This is the example program i found in the forum.
    import java.awt.BorderLayout;
    import java.nio.charset.Charset;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    import javax.swing.SwingUtilities;
    import javax.swing.event.DocumentEvent;
    import javax.swing.event.DocumentListener;
    public class TestSBC {
    public static void main(String[] args) {
         SwingUtilities.invokeLater(new Runnable() {
         @Override
         public void run() {
              new TestSBC().createGUI();
    private void createGUI() {
         JFrame frame = new JFrame();
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         final JLabel messageLabel = new JLabel("Here comes a message",
              JLabel.CENTER);
         final JTextField textField = new JTextField();
         textField.getDocument().addDocumentListener(new DocumentListener() {
         @Override
         public void changedUpdate(DocumentEvent e) {
              checkEvent(e);
         @Override
         public void insertUpdate(DocumentEvent e) {
              checkEvent(e);
         @Override
         public void removeUpdate(DocumentEvent e) {
              checkEvent(e);
         private void checkEvent(DocumentEvent e) {
              messageLabel
                   .setText(validateText(textField.getText()) ? "KATAKANA"
                        : "other");
         frame.add(messageLabel, BorderLayout.PAGE_END);
         frame.add(textField, BorderLayout.CENTER);
         frame.pack();
         frame.setLocationRelativeTo(null);
         frame.setVisible(true);
    private boolean isKatakana(char c) {
         Character.UnicodeBlock unicodeBlock = Character.UnicodeBlock.of(c);
         System.out.println("unicodeBlock : " + unicodeBlock);
         boolean isKatakana = Character.UnicodeBlock.KATAKANA
              .equals(unicodeBlock);
         System.out.println(isKatakana);
         return isKatakana;
    private boolean validateText(String text) {
         char[] chars = text.toCharArray();
         for (char c : chars) {
         if (isKatakana(c)) {
              return true;
         return false;
    Thanks for your help...

    Hi Joerg22
    Thanks for your response.
    Can you please tell me ...is there any another ways to find the "input locale" value in java.
    There are 3 important locales in Windows: “Input Locale”, “User Locale” and “System Locale” and all 3 can be different.
    That is you can have System Locale = English, Input Locale = Chinese and User Locale = Japanese
    This might represent a Chinese user working in japan on an English PC.
    In this example i want to identify Input Locale means "Chinese "
    Thanks for your help.

  • How to get current time and date??

    How to get current time and date from my PC time and date to the java application??
    i use java.util.* package but got error, that is:
    - java.util.* and java.sql.* class are match
    - abstract class cannot be instantiated
    so what can i do, pls guide...thanks...

    There is a method in the System class that will return the current system time. You could also instantiate a Date, Time, Timestamp, or Calendar object, all of which get created with the system time by default.
    Don't import *. Import the specific classes you need.
    Next time, post the actual text of the exceptions/compile errors. If you make people guess, most just won't bother.

  • How to get server time in Oracle Internet Directory (OID)?

    Hi,
    How to get current time on OID server? As in case AD, RootDSE contains currentTime attribute, Is there any attribute in OID through which I can get current time on server.
    Thanks in advance for any help.
    Regards,
    Umesh

    Hi,
    wrong forum, use Identity Manager
    Frank

  • How to get a time from a NTP server in ActionScript 3 ?

    Dear All,
    I need your advice, how to get the time from NTP Server , I tried to do this, but I don't.
    Thanks
    Omar Mahmoud

    you must use a server-side language supported by your server.  php is a commonly supported language on most servers.
    php tutorials can be found via google or any other search engine.

  • How to get duration time

    Hi all,
    I have problem how to get duration time between 2 date time (calendar):
    example :
    Calendar startDateTime
    Calendar stopDateTime
    how to get :
    ???? duration = stopDateTime - startDateTime
    Thanks before

         Calendar one = new GregorianCalendar();
         Thread.currentThread().sleep( 1000 );
         Calendar two = new GregorianCalendar();
         long time = two.getTimeInMillis() - one.getTimeInMillis();
         System.out.println( "Hrs   " + Math.round( time / ( 1000 * 60 * 12 ) ) );
         System.out.println( "Mins  " + Math.round( time / ( 1000 * 60 ) ) );
         System.out.println( "Secs  " + Math.round( time / 1000 ) );     
         System.out.println( "MSecs " + time );

  • How to get the time interveral for each status of worklow (wating,Inprocess

    Hi Friends,
    I have requreiemnt to get the time interval for each status of workflow.
    ex.
                                                                     status
    workflow id  | startd date | enddate       | waiting | Inprocessing|Error|......
    1026            10.10.2008  25.10.2008        1hr      1hr 30 min    2 hr
    Please do give me idea how to get the time stam of each status of workflow.
    Thanks,
    D.prabhu

    Hi,
    I think the following tables would be helpful to you:-
    SWW_CONT     Container Contents for Work Item Data Container
    SWW_CONTOB     "Container Cont. for Work Item Data Container (Only Objects)"     
    SWWLOGHIST     History of a work item     
    SWWORGTASK     Assignment of WIs to Org.Units and Tasks     
    SWWUSERWI      Current Work Items Assigned to a User     
    SWWWIHEAD     Header Table for all Work Item Types
    Hope it Helps!
    Regards,
    Kanika

  • How to get GMT time in Millis?!

    Hello,
    I'm trying to get the currentime in millis as per GMT timezone.
    GregorianCalendar c = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
                        java.util.Date d =  c.getTime();
                        timeNow =  new Timestamp(d.getTime());This is just one of the attempts. Could someone point me out with code, without having to use Joda Library?

    right, but actually one needs not to be bothered about the DB. The question is simple:
    I've a Timestamp in GMT (a).
    I want to compare it to the current time. How to do?
    I can convert a into millis.
    Now how can I get in millis what's the time in GMT??
    I thought this would work:
    Calendar c  = GregorianCalendar.getInstance(tz);
                        c.set(Calendar.SECOND, 0);
                        c.set(Calendar.MILLISECOND, 0);
                        long cc = c.getTimeInMillis();
    Timestamp result = Timestamp.valueOf(rs.getObject(sessionStartTimeColumn.getName()).toString());
                        result.setNanos(0);
                        result.setSeconds(0);
                        long rr = result.getTime();
                        assertEquals(cc,rr);But the problem, persists, c.getTimeInMillis() will not give the millis as if in GMT. So that's the real problem, that's breaking my nerves. I understand why it's happening, but no way around??
    Can someone tell me how to get the millis that someone in GMT would get using System.currentTimeMillis()??
    PS: I don't use rs.getTimestamp() because the JDBC I'm using seems to have a bug there.

  • How to Make a Timer with Milliseconds

    I am trying to create a timer that tracks milliseconds. The reason being is that I want to track key strokes, store them, and later repeat them. In order to repeat each key's input interval accurately, I need to
    track amount of time each key is pressed between each other and to do so I plan to record by the millisecond. I won't be storing each millisecond but rather I want to make sure that the Controls.TextType and Timer event can be processed at any moment. From
    my observation, I can't go any lower than one second because, realistically, multiple keys can be pressed in less than a second and also I can't recreate one second (accurately) out of milliseconds unless its ticking by one millisecond. As far as I know, I
    can use the Timer object but I encountered a limitation. The Timer.Interval only goes as low as 10 milliseconds. I looked at other options and considered using Clock.Millsecond and subtracting two versions of Clock.Millisecond at a millisecond difference but
    did not manage to make a working sample.
    I also tried using using Program.Delay() but I don't understand how this doesn't measure one millisecond:
    gw = 600
    gh = 300
    GraphicsWindow.Width = gw
    GraphicsWindow.Height = gh
    GraphicsWindow.KeyDown = onKeyDown
    GraphicsWindow.KeyUp = onKeyUp
    GraphicsWindow.Left = 0
    GraphicsWindow.Top = (Desktop.Height - gh)*0.20
    TextWindow.Left = (Desktop.Width - gw)*0.90
    TextWindow.Top = (Desktop.Height - gh)*0.20
    txtSize = 20
    tx = (gw - txtSize)*0.20
    ty = (gh - txtSize)*0.50
    GraphicsWindow.FontSize = txtSize
    GraphicsWindow.DrawText(tx,ty,"CLICK GRAPHICS WINDOW SCREEN THEN")
    GraphicsWindow.DrawText(tx,ty+txtSize,"PRESS ENTER TO USE KEY EVENT")
    milliSec = 0
    sec = 0
    print = "True"
    While "True"
    milliSec = milliSec + 1
    If (milliSec > 999) Then
    milliSec = 0
    sec = sec + 1
    TextWindow.WriteLine(sec)
    EndIf
    If (keyDown["Return"] And print = "True") Then
    TextWindow.WriteLine("You pressed at " + sec + ":" + milliSec)
    print = "False"
    ElseIf (keyDown["Return"] <> "True") Then
    print = "True"
    EndIf
    Program.Delay(1)
    EndWhile
    Sub onKeyDown
    lastKey = GraphicsWindow.LastKey
    keyDown[lastKey] = "True"
    EndSub
    Sub onKeyUp
    lastKey = GraphicsWindow.LastKey
    keyDown[lastKey] = "False"
    EndSub
    Why do I suspect my timer isn't accurate? For one, when I count by one (like so one crocodile, two crocodile, etc) it doesn't match up. Also, I've compared it with many online stop watches and it's apparent they run seconds ahead.
    My three options:
    1) use the Timer object
    2) use Clock.Millisecond
    3) use Program.Delay
    After constant failure and researching, I forgot to consider what is the default rate of a small basic program when its running as a whole and each line. Is it possible to go lower than it? Again the current goal
    of my project at the moment is tracking a key stroke and returning the time the user inputted. That's why, I want my timer to move
    by one millisecond so I am able to process every action. Any explanation, samples, or guidance would be helpful. Thank you.

    Program Code: FRT619
    Removing the comments tags (from the last three lines at the bottom of the mainTimer subroutine) will show that I can store time values and rely on the fact that they can be compared. It's no where near completion
    but, hypothetically, this will allow me to achieve my main goal: storing time intervals from any key and repeat them at the user's command accurately when the timer restarts. I'm sure I've compromised the timer's accuracy though. What are your thoughts? Do
    you see a better way to approach this problem? Also, I wasn't able to display the milliseconds but realized that it may not be necessary since I only need it to process events and store variable accurately. Not to display the precise time. Although, I am open
    to any solutions to this minor problem. One more note: I nested the main loop with a small loop that changes run to true when milliseconds is zero. This is used to assure that milliSec has an initial value of zero, which is crucial to store time accurately.
    Bug: Timer stops if user holds enter key. Solution: remove program delay in sub routine control, however, user can't hold key and record same key multiple times.
    New Solution to bug: implement button and textbox events (allows user input while recording time through PC's clock--in milliseconds).
    On a side note, the clock object communicates with the PC's clock, which would mean it's asynchronous from the program and isn't affected by program delay. However, if the PC's clock is ticking by the millisecond(s) and the program stores the time from the
    PC's clock and display it with a delay of 1000 milliseconds. The clock object may not be affect but displaying the time will be?

  • How to get system time from cRIO?

    Hello,
    I have an NI cRIO-9076 chassis with an NI-9467 GPS module and an NI-9234 module.
    I've downloaded the FPGA Timekeeper application which synchronises the FPGA clock to the 1PPS GPS, this works well.  What I want to do is create a trigger that at a pre-defined HH:MMS the system will start to acquire and log data from the Accelerometers connected to the NI-9234 module.
    I have added the controls for the entry of the HH:MMS and calculated the time in seconds.  I would like to compare the system clock once it is locked to the entered timestamp and then trigger.
    As I only have a value that represents seconds in the day I need to calculate the offset from EPOCH to compare against the GPS time reference.  I have read that the NI system clock runs from 01/01/1904 instead of the EPOCH 01/01/1970.
    The question is how do I get the current system time so that I can compare it against the entered time?  I only need seconds in the day = (HH * 3600) + (MM * 60) + (SS)
    Thank you,
    Kind Regards,
    Simon

    You should use the Get Date/Time in Seconds VI which will return a timestamp. You can then format this timestamp using the Format Date/Time String to give you exactly the time format that you need. Then you can extract the numbers you need and do your math.
    www.movimed.com - Custom Imaging Solutions
    Attachments:
    Get Seconds in Day.vi ‏9 KB

  • How to get real time information about how many user are logged in and thei

    I use tomcat as my server platform in Ubuntu for a war file.
    I know in order to get real time information about how many user are logged in, we can count how many active sessions exist by a SessionCounter code. However, I have to permit HttpSessionListener in web.xml of tomcat. From other users' experiences, the configuration is complexed and has some errors.
    Here's the link:http://www.stardeveloper.com/article...1112001&page=1
    In order to get users' ip, in jsp, use request.getremotehost() or
    request.getremoteaddress() by editing the jsp file.
    I wonder if there's some open source software to use for these two purposes.
    Thank you!

    That url is missing a few bits. The ... in the middle doesn't help.
    we can count how many active sessions exist by a SessionCounter code.
    However, I have to permit HttpSessionListener in web.xml of tomcat.
    From other users' experiences, the configuration is complexed and has some errors.And have you tried it? The configuration isn't that complex.
    What errors do you mean? Errors in tracking people, variance in the count? Probably related to internet issues and nothing you can do will alleviate them.

  • How to get a time part from Date datatype

    Hi,
    I would like to know how to extract the timestamp alone from DATE datatype? If my input is '27-SEP-2011 23:59:00' I need the output as 23:59:00. I am surprised to see that there are no in-built functions for this or may be I am wrong. Basically I need to remove the date part from DATE data type and get the time.Please assist.
    -Thanks
    Edited by: user9546145 on Sep 27, 2011 2:24 PM
    Edited by: user9546145 on Sep 27, 2011 2:25 PM

    Hi,
    user9546145 wrote:
    Hi,
    I would like to know how to extract the timestamp alone from DATE datatype? Be careful! In Oracle, TIMESTAMP means a datatype, similar to but distinct from DATE. You'll avoid confusion if you don't use the word "timestamp" to mean anything else.
    There is a built-in function, TO_CHAR:
    TO_CHAR (dt_col, 'HH24:MI:SS')Depending on how you plan to use the time, TRUNC is another handy built-in function:
    dt_col - TRUNC (dt_col)is a NUMBER (not less than 0, but less than 1) which is suitable for many tasks, such as finding the average time.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.

  • How to get elapsed time of the query in form 6i

    hi
    I used to use " set timing on " in sql to get the elapsed time
    set timing on
    elapsed time :XX:XX:XX ,
    but i dont know how to get it in fom
    its really imporant to measure the time elapsed for me cuz i am student an need to get the time
    thanx alot

    regarding to point 1 : u know there are three modes for system ; query, enter_qeury,and normal. when the system is not noraml so it is either query or enter_query , and both are query processing ( as i think) so it the elapsed time . it also by using timer stpos when system finish query ( normal)
    why you dont prefer timers ..... ( it important please to explain )
    thank you very much Navnit Punj
    Edited by: user8652693 on 22/07/2009 07:33 ص

  • How to get current time in TimesTen

    I need to get the current timestamp of TimesTen DB located node, how can get it?
    In PSQL, I can use built-in function now(), In Oracle, I can use LOCALTIMESTAMP, thanks. a lot.

    Hi Vikas,
    Firstly, the syntax you give
    select to_char(sysdate,'dd-mm-yyyy hh24:mi:ss.FF') as ts from dual;
    does not work in Oracle DB - it gives an eror due to the '.FF' in the format string.
    This syntax does work just fine in TimesTen (which is a little more tolerant).
    However, this is not a very useful thing since the resolution of SYSDATE is 1 second and to accurately measure data fetch times you need accurate microsecond resolution. Also, you would need to take an average over many millions of measurements to get any degree of accuracy.
    Realistically, this will be a very difficult thing to measure with any accuracy. Might I understand what you are exactly looking to achieve here? For the same amount of data, separateing 'fetch' from SQL execution, TimesTen in direct mode will return data much, much faster than an Oracle client/server connection wven when the client is on the same machine as oracle. For Tt client/server mode the data transfer performance will be very similar to that for Oracle.
    Chris

  • How to get current time

    Hi,
    I would like to know how to get the current time (07H25 for instance).
    Does someone know how to do it ?
    Thanks in advance, Fred.

    java.util.Date = new java.util.Date();
    The above code produces an object which contains a timestamp (date and time) for the instance in which it was created.
    To display it in any format you wish you would use the java.text.SimpleDateFormat class.

Maybe you are looking for