Message10378

Author DanglingPointer
Recipients DanglingPointer, zyasoft
Date 2015-10-24.01:43:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1445650988.62.0.21372033782.issue2411@psf.upfronthosting.co.za>
In-reply-to
Content
What if we just get the java.lang.System.nanoTime() into a variable whenever jython starts and hybridize the call to datetime?

Something similar to this solution in Java...
/**
 * From http://stackoverflow.com/questions/1712205/current-time-in-microseconds-in-java
 * Class to generate timestamps with microsecond precision
 * For example: MicroTimestamp.INSTANCE.get() = "2012-10-21 19:13:45.267128"
 */ 
public enum MicroTimestamp 
{  INSTANCE ;

   private long              startDate ;
   private long              startNanoseconds ;
   private SimpleDateFormat  dateFormat ;

   private MicroTimestamp()
   {  this.startDate = System.currentTimeMillis() ;
      this.startNanoseconds = System.nanoTime() ;
      this.dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS") ;
   }

   public String get()
   {  long microSeconds = (System.nanoTime() - this.startNanoseconds) / 1000 ;
      long date = this.startDate + (microSeconds/1000) ;
      return this.dateFormat.format(date) + String.format("%03d", microSeconds % 1000) ;
   }
}
History
Date User Action Args
2015-10-24 01:43:08DanglingPointersetmessageid: <1445650988.62.0.21372033782.issue2411@psf.upfronthosting.co.za>
2015-10-24 01:43:08DanglingPointersetrecipients: + DanglingPointer, zyasoft
2015-10-24 01:43:08DanglingPointerlinkissue2411 messages
2015-10-24 01:43:07DanglingPointercreate