public class TestTimer {
public void showTimer () {
TimerTask task = new TimerTask () {
@ Override
public void run () {
System.out.println (" executed " ) ;
}
};
Calendar calendar = Calendar.getInstance ();
int year = calendar.get (Calendar.YEAR);
int month = calendar.get (Calendar.MONTH) + 1;
int day = calendar.get (Calendar.DAY_OF_MONTH);
calendar.set (year, month, day, 13, 22, 0);
Date date = calendar.getTime ();
Timer timer = new Timer (true);
timer.schedule (task, date);
}
}
MainForm.Java
public class MainForm extends JFrame {
TestTimer m_Timer = new TestTimer ();
public MainForm () {
.......
m_Timer.showTimer ();
}
.......
}
Thank you
------ Solution ---------------------------------- ----------
int month = calendar.get (Calendar.MONTH) + 1;
you regard the time fixed in the next month, how will immediately see the results . .
------ For reference only -------------------------------------- -
nobody knows yet
------ For reference only ------------------------------ ---------
Thank you :) ..............
------ For reference only --------- ------------------------------
tangled it
没有评论:
发表评论