我一直坚持这个问题。用户将设置自定义警报间隔,然后在选择器上选择日期,并将应用程序设置为显示下一个警报。如果他们在过去设置它,我希望应用程序通过循环添加间隔,直到将来。
我一直在玩日期比较,但我似乎无法得到任何工作。你们怎么做到这一点?谢谢!
答案 0 :(得分:1)
您可以添加此扩展程序以检查其日期是否在指定日期之前:
@Configuration
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/**").resourceChain(true)
.addResolver(new VersionResourceResolver().addContentVersionStrategy("/**"));
}
@Bean
public ResourceUrlEncodingFilter resourceUrlEncodingFilter() {
return new ResourceUrlEncodingFilter();
}
}
要使用它,只需执行类似
的操作extension NSDate
{
func isGreaterThanDate(dateToCompare : NSDate) -> Bool
{
//Declare Variables
var isGreater = false
//Compare Values
if self.compare(dateToCompare) == NSComparisonResult.OrderedDescending
{
isGreater = true
}
//Return Result
return isGreater
}
func isLessThanDate(dateToCompare : NSDate) -> Bool
{
//Declare Variables
var isLess = false
//Compare Values
if self.compare(dateToCompare) == NSComparisonResult.OrderedAscending
{
isLess = true
}
//Return Result
return isLess
}
}
然后添加你可以做的间隔
let today = NSDate()//this creates a date object with current date
let isBeforeToday = today.isGreaterThanDate(aDate)//aDate is whatever date they pick from the picker
我不确定我确切知道你想做什么,但至少应该让你开始比较日期并为它们添加间隔