41 lines
1.1 KiB
Java
41 lines
1.1 KiB
Java
package com.simulationservice.service;
|
|
import java.io.IOException;
|
|
import java.lang.*;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
|
|
import com.simulationservice.service.CustomThread;
|
|
/**
|
|
* 时间同步线程,用于处理想定的倒计时和想定时间结束
|
|
*/
|
|
public class TimeSyncThread extends CustomThread {
|
|
|
|
private String beginTime; //开始时间
|
|
private long continueTime; //持续时间
|
|
|
|
@Override
|
|
public void processBuss() {
|
|
|
|
//系统当前时间倒计时
|
|
Date date = new Date();
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
String formattedDate = sdf.format(date);
|
|
System.out.println(formattedDate);
|
|
|
|
//String dateString = "2023-04-01 12:00:00";
|
|
|
|
try {
|
|
Date dateT = sdf.parse(beginTime);
|
|
System.out.println(dateT);
|
|
} catch (ParseException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public void setBeginTime(String beginTime) {
|
|
this.beginTime = beginTime;
|
|
}
|
|
|
|
}
|