Function that creates a timestamp in c#

I always use something like the following: public static String GetTimestamp(this DateTime value) { return value.ToString(“yyyyMMddHHmmssfff”); } This will give you a string like 200905211035131468, as the string goes from highest order bits of the timestamp to lowest order simple string sorting in your SQL queries can be used to order by date if you’re … Read more

System.currentTimeMillis vs System.nanoTime

If you’re just looking for extremely precise measurements of elapsed time, use System.nanoTime(). System.currentTimeMillis() will give you the most accurate possible elapsed time in milliseconds since the epoch, but System.nanoTime() gives you a nanosecond-precise time, relative to some arbitrary point. From the Java Documentation: public static long nanoTime() Returns the current value of the most … Read more