如何获得一周的日期(我知道周数)? [英] How to get dates of a week (I know week number)?

查看:81
本文介绍了如何获得一周的日期(我知道周数)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道一年中的周数,一周从星期日开始,然后是星期一,星期二......星期六。

I know the week number of the year, a week is start from Sunday, then Monday, Tuesday...,Saturday.

因为我知道周数,使用Java代码获取特定周的日期的有效方法是什么?

Since I know the week number, what's the efficient way to get the dates of the specific week by using Java code??

推荐答案

如果你不想要外部库,只需使用日历。

If you don't want external library, just use calendar.

SimpleDateFormat sdf = new SimpleDateFormat("MM dd yyyy");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.WEEK_OF_YEAR, 23);        
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
System.out.println(sdf.format(cal.getTime()));    

这篇关于如何获得一周的日期(我知道周数)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆