我的 mongoDb 集合中有一些数据和字段名称billingDate,其中我以 ISO 格式存储账单日期,如下所示。
{
"_id":"xxyy",
"name":"abcd",
"billingDate":ISODate("2018-01-03T13:50:05.000+0000"),
}
Run Code Online (Sandbox Code Playgroud)
我想查询我的集合的日期范围,例如获取从一个日期到另一个日期的所有账单。为了实现这一点,我从用户那里获取日期,然后将其转换为 mongoDb 的匹配格式。
fromTime // value from user in format("dd/mm/yyyy")
toTime // value from user in format("dd/mm/yyyy")
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd/MM/yyyy");
dtf = dtf.withLocale(Locale.US); // Locale specifies human language for translating, and cultural norms for lowercase/uppercase and abbreviations and such. Example: Locale.US or Locale.CANADA_FRENCH
LocalDate fdate = LocalDate.parse(fromTime, dtf);
LocalDate tdate = LocalDate.parse(toTime, dtf);
System.out.println("date is :: "+fdate);
LocalDateTime flocalDateTime=LocalDateTime.of(fdate, LocalTime.MIDNIGHT);
Instant finstant=flocalDateTime.toInstant(ZoneOffset.UTC);
LocalDateTime tlocalDateTime=LocalDateTime.of(tdate, LocalTime.MIDNIGHT);
Instant tinstant=tlocalDateTime.toInstant(ZoneOffset.UTC); …Run Code Online (Sandbox Code Playgroud) 我已经浏览了其他线程并使用了一个作为参考,但仍然无法找到解决方案。
我的问题是:
我正在按钮单击时调用一个函数,该函数在验证后已验证我试图在提交处理程序中使用 ajax 请求发布数据,问题是我的字段正在得到验证,但未调用 Ajax 请求。
<input type="button" value="Register" id="registerP" onclick="registerPatient()" class="form-control input-sm btn-success ">
function registerPatient(){
$("#patientRegistration").validate({
rules: {
patientName: {
required: true,
textOnly: true
},
},
messages: {
patientName: {
required: "Please enter the full name",
},
},
submitHandler: function(form) {
$.ajax({
type: "POST",
url: "/LoginMavenSpringMVC/appointment/savePatient",
data: "patientName=" + patientName,
success: function(response){},
error: function(e){}
});
}
});
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我不使用验证并直接调用 Ajax,我就可以发布数据。请建议我要去哪里错了。