Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit cac6ade

Browse files
authored
Merge pull request #1072 from fuwei123456/fixDateFormat2
Replace SimpleDateFormat with DateTimeFormatter of Java 8
2 parents 3bc6b6b + 411c3f2 commit cac6ade

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ethereumj-core/src/main/java/org/ethereum/manager/BlockLoader.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
import java.nio.file.Files;
3434
import java.nio.file.Path;
3535
import java.nio.file.Paths;
36-
import java.text.DateFormat;
37-
import java.text.SimpleDateFormat;
36+
import java.time.LocalDateTime;
37+
import java.time.format.DateTimeFormatter;
3838
import java.util.*;
3939
import java.util.function.Function;
4040

@@ -56,7 +56,7 @@ public class BlockLoader {
5656

5757
Scanner scanner = null;
5858

59-
DateFormat df = new SimpleDateFormat("HH:mm:ss.SSSS");
59+
DateTimeFormatter df = DateTimeFormatter.ofPattern("HH:mm:ss.SSSS");
6060

6161
private void blockWork(Block block) {
6262
if (block.getNumber() >= blockchain.getBlockStore().getBestBlock().getNumber() || blockchain.getBlockStore().getBlockByHash(block.getHash()) == null) {
@@ -69,7 +69,7 @@ private void blockWork(Block block) {
6969
ImportResult result = blockchain.tryToConnect(block);
7070

7171
if (block.getNumber() % 10 == 0) {
72-
System.out.println(df.format(new Date()) + " Imported block " + block.getShortDescr() + ": " + result + " (prework: "
72+
System.out.println(LocalDateTime.now().format(df) + " Imported block " + block.getShortDescr() + ": " + result + " (prework: "
7373
+ exec1.getQueue().size() + ", work: " + exec2.getQueue().size() + ", blocks: " + exec1.getOrderMap().size() + ") in " +
7474
(System.currentTimeMillis() - s) + " ms");
7575
}

0 commit comments

Comments
 (0)