---
title: "根据输入的日期 获得当前日期为周几"
author: "daoshud1"
date: "2012-11-06T11:28:00Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2012-11-06T11:28:00Z"
id: 1717362
url: "https://daoshud1.iteye.com/blog/1717362"
---

```java

public static String getWeekOfDate(Date dt) {
        String[] weekDays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
        Calendar cal = Calendar.getInstance();
        cal.setTime(dt);
        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (w < 0)
            w = 0;
        return weekDays[w];
    }

```