Created
January 22, 2024 01:52
-
-
Save dotrinh-DM/bb1e67e4fedb30a8e7ce324cd8f7c876 to your computer and use it in GitHub Desktop.
calculate duration of transaction Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Created by dotrinh on 7/21/20 12:28 PM | |
*/ | |
package jp.co.zoom.handyrecorder.tool; | |
/** | |
* calculate duration of transaction | |
* | |
* Usage: | |
* Start: | |
* TransactionTime transactionTime = new TransactionTime(System.currentTimeMillis()); | |
* | |
* End: | |
* transactionTime.setEnd(System.currentTimeMillis()); | |
* | |
* Check dusration: | |
* transactionTime.getDuration() | |
*/ | |
public class TransactionTime { | |
public long start; | |
public long end; | |
public TransactionTime() { | |
} | |
public TransactionTime(long start) { | |
this.start = start; | |
} | |
public void setEnd(long end) { | |
this.end = end; | |
} | |
/** | |
* Get duration of transaction in millisecond | |
* @return | |
*/ | |
public long getDuration() { | |
if (this.start > 0 && this.end > 0) { | |
return this.end - this.start; | |
} else { | |
return 0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment