我试图按时间范围查询Elasticsearch索引,另外还有一个术语匹配特定的字符串值.
我试过这个查询,看起来非常简单:
{
"query" : {
"bool": {
"must": [
{
"match": {
"method": "/customer/help"
}
},
{
"range" : {
"startTime": {
"from" : "2015-10-20T13:00-04:00",
"to" : "2015-10-20T14:00-04:00"
}
}
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我希望在给定时间范围内的所有文档也具有方法值"/customer/help".
在我的结果中,我收到的时间范围内的结果,但是"method"当我只想"/customer/help"在该字段中获得结果时,我会获得具有该字段的各种值的文档.
我有一个简单的网络界面,以"2009/10/09 11:00"或"yyyy/MM/dd HH:mm"的形式显示日期和时间.时间(从用户的角度来看)是在东部时间.
我希望能够获取此字符串,将其转换为UTC时间戳,因此我可以根据指定的时间获取此时间戳并查询我们的NoSQL数据库.
我的代码如下:
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm");
LocalDateTime dateTime = LocalDateTime.parse(startSearchTime, formatter);
System.out.println(dateTime);
LocalDateTime utcTime = dateTime.plusHours(4);
Instant instant = Instant.parse(utcTime.toString());
System.out.println(instant.toEpochMilli());
Run Code Online (Sandbox Code Playgroud)
我从UI获取字符串并将其存储在'startSearchTime'中.我将其从东部时间转换为UTC,增加4小时.然后我尝试创建一个即时对象并解析字符串并获得纪元毫秒,但我得到的异常是:
"文字'2015-10-16T14:00z'无法解析"
有了这个新的Java 8 DateTime API,我认为这个任务很简单,我缺少什么?!
我正在尝试使用 Spring Boot 和 Thymeleaf 创建一个简单的导航栏,其中包含指向其他网站/服务器的链接。我想将这些 URL 存储在我的“application.properties”中并通过 th:href 访问它们。当我尝试访问它们时,它不会将我重定向到此 URL。
这是 HTML:
<li class="dropdown-submenu">
<a tabindex="-1" href="#">Menu</a>
<ul class="dropdown-menu">
<li><a th:href="#{foo.bar}">Selection 1</a></li>
Run Code Online (Sandbox Code Playgroud)
在 application.properties 中:
foo.bar=http://www.example.com
Run Code Online (Sandbox Code Playgroud) datetime ×1
epoch ×1
html ×1
java ×1
json ×1
milliseconds ×1
spring ×1
spring-boot ×1
thymeleaf ×1