Skip to content

Commit 670ce91

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 d27d01a)
1 parent 9ce8f07 commit 670ce91

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

‎.gitignore

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
1-
.idea/
1+
# Compiled class files
2+
*.class
3+
4+
# Log file
5+
*.log
6+
**/.log
7+
8+
# IntelliJ
29
*.iml
10+
/.idea
11+
12+
# Package Files #
13+
*.jar
14+
*.war
15+
*.nar
16+
*.ear
17+
*.zip
18+
*.tar.gz
19+
*.rar
20+
21+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
22+
hs_err_pid*
23+
24+
# other
25+
/bin/
26+
/.classpath
27+
/.project
28+
/target/
29+
/out/
30+
/.DS_Store
31+
/.settings/
32+

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

+14-1
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,25 @@ public LocalDateTime getTimeStamp() {
6060
if(_timeStamp == null && !BasicUtils.isEmpty(timeStamp)) {
6161
long formatted = (timeStamp.charAt(0) == '0' && timeStamp.charAt(1) == 'x')
6262
? BasicUtils.parseHex(timeStamp).longValue()
63-
: Long.valueOf(timeStamp);
63+
: Long.parseLong(timeStamp);
6464
_timeStamp = LocalDateTime.ofEpochSecond(formatted, 0, ZoneOffset.UTC);
6565
}
6666
return _timeStamp;
6767
}
6868

69+
/**
70+
*
71+
* @return
72+
*/
73+
public Long getTimeStampAsMillis() {
74+
if (BasicUtils.isEmpty(timeStamp)) {
75+
return null;
76+
}
77+
return (timeStamp.charAt(0) == '0' && timeStamp.charAt(1) == 'x')
78+
? BasicUtils.parseHex(timeStamp).longValue()
79+
: Long.parseLong(timeStamp) * 1000;
80+
}
81+
6982
public String getData() {
7083
return data;
7184
}

0 commit comments

Comments
 (0)