mirror of
https://github.com/tiennm99/time-mocker.git
synced 2026-10-11 03:13:47 +00:00
feat(core): add logic log current localdatetime every seconds
This commit is contained in:
1 parent
ed66ebedc2
commit
d1282fb97c
1 file changed
+9
-12
@@ -1,18 +1,15 @@
|
||||
package com.miti99;
|
||||
|
||||
// TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
|
||||
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Main {
|
||||
|
||||
static void main() {
|
||||
// TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
|
||||
// to see how IntelliJ IDEA suggests fixing it.
|
||||
IO.println(String.format("Hello and welcome!"));
|
||||
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
// TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
|
||||
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
|
||||
IO.println("i = " + i);
|
||||
}
|
||||
static void main() throws InterruptedException {
|
||||
var executor = Executors.newSingleThreadScheduledExecutor();
|
||||
executor.scheduleAtFixedRate(() -> IO.println(LocalDateTime.now()), 1, 1, TimeUnit.SECONDS);
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(executor::shutdown));
|
||||
Thread.currentThread().join();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user