import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* 倒计时
*/
public class Counter {
private JFrame frame;
private JLabel jl0;
private ScheduledThreadPoolExecutor scheduled;
public static void main(String[] args) {
new Counter().timer("2017-09-20 21:06:00");
}
/* String -> Date */
private Date String2Date(String dateStr) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date date = simpleDateFormat.parse(dateStr);
if (date.getTime() <= System.currentTimeMillis()) {
jl0.setText("时间不能早于现在" + dateStr);