<pre name="code" class="java">package com.asia.sun.demo4;
import java.util.Calendar;
import java.util.Date;
public class GetSwitch {
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
c.setTime(new Date(System.currentTimeMillis()));
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
switch(dayOfWeek){
case 1:
System.out.println("周天");
break;
case 2:
System.out.println("周一 ");
break;
case 3:
System.out.println("周二");
break;
case 4:
System.out.println("周三");
break;
case 5:
System.out.println("周四");
break;
case 6:
System.out.println("周五");
break;
case 7:
System.out.println("周六");
break;
default:
System.out.println("Sorry, I dont't Know");
}
}
}
switch case显示当日周天信息
最新推荐文章于 2022-04-03 21:15:58 发布