Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4a570d2

Browse files
iSnowGoodforGod
authored andcommitted
Method to get an event time stamp as milliseconds since the Unix epoch to avoid time zone calculations
(cherry picked from commit 8de0601)
1 parent 670ce91 commit 4a570d2

File tree

1 file changed

+6
-4
lines changed
  • src/main/java/io/api/etherscan/model

1 file changed

+6
-4
lines changed

‎src/main/java/io/api/etherscan/model/Log.java‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,18 @@ public LocalDateTime getTimeStamp() {
6767
}
6868

6969
/**
70-
*
71-
* @return
70+
* Return the "timeStamp" field of the event record as a long-int representing the milliseconds
71+
* since the Unix epoch (1970年01月01日 00:00:00).
72+
* @return milliseconds between Unix epoch and `timeStamp`. If field is empty or null, returns null
7273
*/
7374
public Long getTimeStampAsMillis() {
7475
if (BasicUtils.isEmpty(timeStamp)) {
7576
return null;
7677
}
77-
return (timeStamp.charAt(0) == '0' && timeStamp.charAt(1) == 'x')
78+
longtsSecs = (timeStamp.charAt(0) == '0' && timeStamp.charAt(1) == 'x')
7879
? BasicUtils.parseHex(timeStamp).longValue()
79-
: Long.parseLong(timeStamp) * 1000;
80+
: Long.parseLong(timeStamp);
81+
return tsSecs * 1000;
8082
}
8183

8284
public String getData() {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /