From: Peter K on 2 Mar 2010 02:09 Hi I have a c# application which reads data from a database. Some of the data is a "time" which is actually a c# "ticks" value (written to the db by another c# application). Now I am writing a java application, which collects data and writes it to the database for the c# application to read. So how do I convert a java "Date" to a value which the c# application can interpret as "ticks"? Thanks, Peter
From: Frank Langelage on 2 Mar 2010 03:04 On 02.03.10 08:09, Peter K wrote: > Hi > > I have a c# application which reads data from a database. Some of the > data is a "time" which is actually a c# "ticks" value (written to the db > by another c# application). > > Now I am writing a java application, which collects data and writes it > to the database for the c# application to read. So how do I convert a > java "Date" to a value which the c# application can interpret as "ticks"? > First you should use a more common DB schema instead of this proprietary one. Second you should have provided the definition of ticks: From MSDN: A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond. The value of this property represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001. java.util.Date has a constructor public Date(long date) with date as the number of milliseconds since January 1, 1970, 00:00:00 GMT. So this should be no problem for a programmer to solve this now.
From: Peter K on 2 Mar 2010 03:44 "Frank Langelage" <frank(a)lafr.de> wrote in message news:7v3v49Fsj9U1(a)mid.individual.net... > On 02.03.10 08:09, Peter K wrote: >> Hi >> >> I have a c# application which reads data from a database. Some of the >> data is a "time" which is actually a c# "ticks" value (written to the db >> by another c# application). >> >> Now I am writing a java application, which collects data and writes it >> to the database for the c# application to read. So how do I convert a >> java "Date" to a value which the c# application can interpret as "ticks"? >> > > First you should use a more common DB schema instead of this proprietary > one. What would be a better format for the dates? We have found that using a real date field in sql server 2005 gives odd rounding issues - eg dates which are very close to midnight (eg 1 ms before midnight) are rounded up to the next day. We don't want this behaviour, so the c# application was programmed to use the ticks value (where no rounding up to the next day occurs), Using a formatted string for the date makes it harder to select a range of dates (this is very easy with a numeric value). What other/better possibilities are there? Thanks, Peter
From: Lothar Kimmeringer on 2 Mar 2010 06:16 Peter K wrote: > Now I am writing a java application, which collects data and writes it to > the database for the c# application to read. So how do I convert a java > "Date" to a value which the c# application can interpret as "ticks"? Assuming that "ticks" are using NT Time, GIYF giving you e.g. http://support.citrix.com/article/CTX109645 [...] How to convert Windows NT Time to UNIX Time: Divide by 10,000,000 and subtract 11,644,473,600. How to convert UNIX Time to Windows NT Time: Add 11,644,473,600 and multiply by 10,000,000. [...] Regards, Lothar -- Lothar Kimmeringer E-Mail: spamfang(a)kimmeringer.de PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81) Always remember: The answer is forty-two, there can only be wrong questions!
From: Lew on 2 Mar 2010 11:15 Frank Langelage wrote: > java.util.Date has a constructor public Date(long date) with date as the > number of milliseconds since January 1, 1970, 00:00:00 GMT. > So this should be no problem for a programmer to solve this now. Given that the Java type to match databases is java.sql.Timestamp, and that has a resolution of one nanosecond, it's potentially a better choice. -- Lew
|
Next
|
Last
Pages: 1 2 3 4 5 6 Prev: jdbc connection Next: Java/J2EE with Struts | Richmond,VA | 6 months |