time format in SQL Server

You can use a combination of CONVERT, RIGHT and TRIM to get the desired result: SELECT ltrim(right(convert(varchar(25), getdate(), 100), 7)) The 100 you see in the function specifies the date format mon dd yyyy hh:miAM (or PM), and from there we just grab the right characters. You can see more about converting datetimes here.

CPU execution time in Java

System.currentTimeMillis() will only ever measure wall-clock time, never CPU time. If you need wall-clock time, then System.nanoTime() is often more precise (and never worse) than currentTimeMillis(). ThreadMXBean.getThreadCPUTime() can help you find out how much CPU time a given thread has used. Use ManagementFactory.getThreadMXBean() to get a ThreadMXBean and Thread.getId() to find the id of the … Read more

Calculating Future Epoch Time in C#

There is an interesting twist when you want to know the Unix Epoch time in .Net on a Windows system. For nearly all practical cases and assuming the current time is past the Unix Epoch you could indeed take System.TimeSpan timeDifference = DateTime.UTCNow – new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); long unixEpochTime = … Read more

How to convert a time into epoch time?

Use the mktime(3) function. For example: struct tm t = {0}; // Initalize to all 0’s t.tm_year = 112; // This is year-1900, so 112 = 2012 t.tm_mon = 8; t.tm_mday = 15; t.tm_hour = 21; t.tm_min = 54; t.tm_sec = 13; time_t timeSinceEpoch = mktime(&t); // Result: 1347764053

Sync Android devices via GPS time?

You can get the time difference in milliseconds from currentTimeMillis() and Location.getTime() in the onLocationChanged() callback. Use requestSingleUpdate() I just want to add that, if the user has a data connection they can use NTP time, which is even more accurate, as the GPS internal clock might drift and correcting it takes a while. EDIT: … Read more