获取星期几,周一到周日,返回1-7

Posted JLCUI

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取星期几,周一到周日,返回1-7相关的知识,希望对你有一定的参考价值。

 public int getDayOfWeek(Date date) {
  Calendar c = Calendar.getInstance();
  c.setTime(date);
  int d = c.get(Calendar.DAY_OF_WEEK) - 1;
  if (d == 0) {
   return 7;
  }
  return d;
 }

以上是关于获取星期几,周一到周日,返回1-7的主要内容,如果未能解决你的问题,请参考以下文章