Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert a Long data to Date format in LabVIEW 7.0

Hi Shawon,

I need to know the exact output of your Java, I have attached a VI and I need you to follow the instructions.

This VI should allow me to see the exact output you are getting, so I can work out what you need to do.

Once you have run the VI, can you go in to your Java code and change timeStamp = System.currentTimeMillis() inside HumiditySample.java and divide the timeStamp by 1000 as Labview timestamps deal in seconds, and the numbers after the decimal point relate to milliseconds.
After you have changed your code, plese retry with shawonclient-mod.vi

Regards
James
Applications Engineer
NI UK
0 Kudos
Message 11 of 16
(2,004 Views)
Dear james

The situation is getting quite complex at the moment. I have done what u told me to do and it is still the same. I have attached 3 files. which are :

when I convert the timeStamp value to second by deviding 1000 it come out from port "1081339700" which is a long number. I tested it by running the client java program called "DataLoggerClient12" which is reading from the port by using "din.readLong()". this gives "1081339814620" when I pass the time in milisecond format.

but when I run the labVIEW "shawonclient-mod.vi" it is giving me 5.34253E-315 when I convert it to a "double" format.

ur test program I have attached and I am not sure what data t
ype output is coming out. U might have better idea about this I believe.

I have been thinking about this problem. I think this is a both a problem; java and LabView. I saw if the output is 3.16289E+9 which is in "second" range it gives the right time. so from java this time has to come out. but from java it is coming out 1.08134E+9 which is giving a date at 1938. In tini the time format is set on GMT format. is this time format like GMT, CST,PST, PDA making a clush on labview or something. I am not sure. What u suggest at the moment.

waiting for ur reply.

Kind Regards

shawon
Download All
0 Kudos
Message 12 of 16
(2,004 Views)
Dear james

I just have thought in my mind. "currentTimeMillis" in java returs the milisecond between current time and 1st january 1970. while in labview's time stamp starts time from 1904. so here is a 66 years between. so when i feed "1081339700" in labview it gives time in 1938 which is 66 years before. I think its a problem some how.

but I can't feed "1081339700" this in Labview from "TCPRead" VI when i give type cast as a double. I think this is thhe problem going on here. Let me know what u think. Please try to help me.

waiting for ur advice.

shawon
0 Kudos
Message 13 of 16
(2,004 Views)
Hi Shawon,

I had already discovered that, it also seems as if your Java code is sending back time in seconds not msecs.

I attach code that I had working and producing a valid timestamp, you might have to tweak your code to get it fully working, however attached are the 2 files.

Regards
James
Applications Engineer
NI UK
Download All
0 Kudos
Message 14 of 16
(2,004 Views)
Dear James

How are you? Thank you very much for your help. It solved my problem. I had been working yesterday long time to reshape my main application. it is working fine. I am really grateful to you. You are a topman. I never had this much help from anyone from forum. If it is possible please give me your eamil and full name so that I can add your name in the acknowledgemnt section in my project's report. thanks a lot. have a good ester break.

Kind Regards

Mash-Hud Iqbal (Shawon)
London Metropolitan University
email: shawon21@yahoo.com
0 Kudos
Message 15 of 16
(2,004 Views)
Hi Shawon,

Thank you for your kind words, however it is policy not to give out our email address'.

Instead you could mention NIUK tech support or James from NIUK, or just leave me out

Again thank you for your words, and good luck on your project.

Regards
James
Applications Engineer
NI UK
0 Kudos
Message 16 of 16
(2,004 Views)