我正在寻找一种从本地日期(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/