java - 本地日期仅获取周日期Java

标签 java date jodatime

我正在寻找一种从本地日期(JODA TIME)API 仅获取周日期的方法?我正在尝试以这种格式编写代码..

LocalDate today = new LocalDate();
LocalDate getDate = new LocalDate(sqlDate);// i will recieve sqldate from sql table

//if the getdate and number of days to remind is equals to today 
//and if it is between monday to friday ,send an email. 
//ReminderDays is an integer
if(getDate+ReminderDays == today)
SendMail();

如果可以请提供一下代码吗?谢谢。

最佳答案

您可以执行以下操作

1)给getDate加上天数,得到一个newDate

2)与今天的日期进行比较

3) 如果为 true,那么您可以使用 @joe 指定的 getDayOfWeek() 方法,然后检查它是否在 1 和 5 之间(包括 1 和 5)并调用发送邮件方法。

伪代码:

LocalDate getDate = new LocalDate(sqlDate);
LocalDate newDate =getDate.plusDays(int days) ;
if(compare newDate & todays date)
//if true then do
if(1<=newDate.getDayOfWeek()<=5)
//call send mail

关于java - 本地日期仅获取周日期Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15337620/

相关文章:

java - 如何将 SOAP 响应安全地存储在数据库中?

mysql - 将表中日期时间的所有列转换为不同的日期格式

java - 在 JodaTime 中创建特定时区的日期时间对象

java - 格式化 UTC 日期时间的部分秒

java - 如何在 Google App Engine 上创建 RESTful 客户端?

java - 如何在 ICU4J 中获得 "current"IANA 时区缩写?

java - 如何使用 CQRS 进行 BDD?

python - 仅在 pandas 系列日期时间索引中重新设置日期

sql - SQL中如何计算两个日期之间 "Tuesdays"的个数?

java - Joda 时间 DateTime 转换为 java.util.Date 奇怪的问题