package com.red.circle.example.task;

import com.red.circle.tool.core.date.DateUtils;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 * @author pengliang on 2023/11/28
 */
public class TaskTest {

  public static void main(String[] args) {
//    Timer timer = new Timer();
//
//    timer.scheduleAtFixedRate(new TimerTask() {
//      @Override
//      public void run() {
//        System.out.println(DateUtils.formatUtc(DateUtils.now(),"yyyy-MM-dd HH:mm:ss"));
//      }
//    }, 0, 1000);

    var scheduler = Executors.newSingleThreadScheduledExecutor();
    scheduler.scheduleAtFixedRate(
        () -> System.out.println(DateUtils.formatUtc(DateUtils.now(), "yyyy-MM-dd HH:mm:ss")),
        0, 1, TimeUnit.SECONDS);
  }
}
