(安卓)获取周的第一天

由网友(美人鱼出现在我的面前)分享简介:如何获得周的第一天,当我们知道在本周日的一个? How to get first day of week, when we know one of the date in the week? 我知道,当月,当年和周的当前日期。那么,有没有一些方法来了解当前周的第一天。I know the current mon...

如何获得周的第一天,当我们知道在本周日的一个?

How to get first day of week, when we know one of the date in the week?

我知道,当月,当年和周的当前日期。 那么,有没有一些方法来了解当前周的第一天。

I know the current month , the current year and the current date of week. Then, are there some way to know the first day of the current week.

感谢你。

推荐答案

试试这个:

//获得今天晴天的时间

// get today and clear time of day

Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 0); // ! clear would not reset the hour of day !
cal.clear(Calendar.MINUTE);
cal.clear(Calendar.SECOND);
cal.clear(Calendar.MILLISECOND);

//获取本周以毫秒为单位开始

// get start of this week in milliseconds

cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
System.out.println("Start of this week:       " + cal.getTime());
System.out.println("... in milliseconds:      " + cal.getTimeInMillis());

参考:How来得到当前一周和一个月的第一天?

希望这可以帮助你!

阅读全文

相关推荐

最新文章