java 获取今天星期几

package com;

import java.util.*;

public class WhatDay {
 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;

  }

 }

}

你可能感兴趣的:(java 获取今天星期几)