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

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

问题描述

我正在认真寻找这个代码...我是新程序员。

I am seriously looking for this code...I am new programmer.

实际上我想用旗帜制作所有日期,这些都是星期天的特定日期一年。

Actually I want to make all dates with flag, which all are sunday in a particular year.

拜托,我急切地等待你的回复......

Please, I am eagerly waiting for your 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天全站免登陆