如何在Java的特定年份获得星期日的所有日期 [英] How to get all dates of sundays in a particular year in Java

查看:113
本文介绍了如何在Java的特定年份获得星期日的所有日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在认真地寻找这段代码...现在要编程

am seriously looking for this code...am now to programing

其实我想用旗子做所有的日期,这些都是在特定年份的星期日。 plc am eagarly waiting for ur response ....

actually i want to make all dates with flag,which all are sunday in a particulr year.plz am eagarly waiting for ur response....

推荐答案

创建一个新的日历。将时间设置为1/1 / yyyy和一段时间。检查当前日期是否是星期天,然后一天前往。那是今年的第一个星期日。向前滚动7天,直到一年不再匹配,标记为你走。

Create a new calendar. Set the time to 1/1/yyyy and some time. Check if the current date is a Sunday and roll forward one day until it is. That's the first Sunday of the year. Roll forward 7 days until the year no longer matches, marking as you go.

这篇关于如何在Java的特定年份获得星期日的所有日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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