---
title: "根据日期转换星期几的工具类"
author: "cm1993"
date: "2015-08-06T09:55:42Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2015-08-06T09:55:42Z"
id: 2233179
url: "https://cm1993.iteye.com/blog/2233179"
---

public static String getWeekOfDate(Date date)
	{
		String[] weekOfDays={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
		Calendar calendar=Calendar.getInstance();
		if(date!=null)
		{
			calendar.setTime(date);
		}
		int w=calendar.get(Calendar.DAY_OF_WEEK)-1;
		if(w<0)
		{
			w=0;
		}
		return weekOfDays[w];
	}