我有Thymeleaf代码(此代码需要我为JQuery添加参数 - DatePicker):
data-availible-dates="[2014-01-09T00:00:00.000, 2014-01-14T00:00:00.000, 2014-01-10T00:00:00.000, 2014-01-23T00:00:00.000, 2014-01-15T00:00:00.000, 2014-01-06T00:00:00.000, 2014-01-24T00:00:00.000, 2014-01-20T00:00:00.000, 2014-01-16T00:00:00.000, 2014-01-21T00:00:00.000, 2014-01-08T00:00:00.000, 2014-01-22T00:00:00.000, 2014-01-17T00:00:00.000, 2014-01-13T00:00:00.000]"
现在页面看起来像:
data-availible-dates="[1451170800000, 1452380400000, 1452466800000, 1452553200000]"
但我不会像这个例子那样转换为毫秒:
<script type="text/javascript" th:inline="javascript">
/*<![CDATA[*/
var avalibleDates = /*[[${defoultSetting.avalibleDates}]]*/;
/*]]>*/
</script>
我可以使用Thymeleaf并制作类似于JsonDeserializer的东西..在构建页面之前将数据转换为毫秒?
结果:
我决定发送毫秒列表,第二个我现在正在使用下一个代码,以防需要将服务器端的变量添加到JS:
bool <= 0;
d<=-d;
when d>0;
答案 0 :(得分:1)
DateTime
转换为Time(以毫秒为单位):
var myDate = new Date("2012-02-10T13:19:11+0000");
var result = myDate.getTime();
另一方面,如果您需要以毫秒为单位的时间,为什么不在Java端转换它并将处理后的最终变量集(包含以毫秒为单位的时间)发送给Thymeleaf?