java - Time stamp with milliseconds, calculating "delay" -
when create instance of object, say, message m want set field in it, time stamp.
nothing databases.
when object passed around have time stamp read , compared current time of recipient calculate delay = timenow - m.sent_at
. both objects exist on same system , both entities use system's clock (actual time, nothing fancy, delay important), want in milliseconds.
something this:
class message { public final long sentat; public final string data; public message(string data) { this.sentat = system.currenttimemillis() this.data = data; } public long timesincesent() { return system.currenttimemillis() - sentat; } }
Comments
Post a Comment