You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.3 KiB
Java
39 lines
1.3 KiB
Java
package com.example;
|
|
|
|
import com.example.utils.Md5Util;
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.Map;
|
|
import java.util.Timer;
|
|
import java.util.TimerTask;
|
|
|
|
@RunWith(SpringRunner.class)
|
|
@SpringBootTest(classes = com.example.SpringbootDemoApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
public class DemoApplicationTests {
|
|
|
|
@Test
|
|
public void contextLoads() {
|
|
Timer timer = new Timer();
|
|
Date date = new Date();
|
|
int a = 2;
|
|
for (int i = 0; i < a; i++) {
|
|
TimerTask task = new TimerTask() {
|
|
public void run() {
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSSS");
|
|
Long id = Long.valueOf(sdf.format(System.currentTimeMillis()));
|
|
SimpleDateFormat SycTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
System.out.println("id" + id);
|
|
System.out.println("SycTime" + SycTime.format(date));
|
|
}
|
|
};
|
|
timer.schedule(task, 2000);//延迟2秒执行
|
|
}
|
|
}
|
|
}
|