public void time() {
class MyThread extends Thread {
public void run() {
while (Timer) {
// 异步执行一段代码
PlatformUI.getWorkbench().getDisplay()
.asyncExec(new Runnable() {
public void run() {
Calendar now = new GregorianCalendar();
int hour = now.get(Calendar.HOUR_OF_DAY); // 得到小时数
int minute = now.get(Calendar.MINUTE); // 得到分数
int second = now.get(Calendar.SECOND); // 得到秒数
int year = now.get(Calendar.YEAR);
int month = now.get(Calendar.MONTH) + 1;
int day = now.get(Calendar.DAY_OF_MONTH);
int day2 = now.get(Calendar.DAY_OF_WEEK);
String weekend = "";
switch (day2) {
case 1:
weekend = "日";
break;
case 2:
weekend = "一";
break;
case 3:
weekend = "二";
子线程—时钟(字符串输出)
最新推荐文章于 2022-05-05 19:46:11 发布