0
如何將列表從LocalDate轉換爲百里香JavaScript日期列表?將列表從LocalDate轉換爲Javascript日期在thymeleaf
當我剛剛在
var timeaxis = /*[[${timeaxis}]]*/ [];
添加列表,然後我得到的LOCALDATE的改裝成JSON
var timeaxis = [{'chronology':{'calendarType':'iso8601','id':'ISO'},'dayOfMonth':1,'dayOfWeek':{'$type':'DayOfWeek','$name':'TUESDAY'},'dayOfYear':306,'era':{'$type':'IsoEra','$name':'CE'},'leapYear':true,'month':{'$type':'Month','$name':'NOVEMBER'},'monthValue':11,'year':2016}];
當我試圖用格式化的日期https://github.com/thymeleaf/thymeleaf-extras-java8time
var timeaxis = /*[[${#temporals.listFormat(timeaxis, "'new Date('yyyy','MM','d')'")}]]*/ [];
然後我得到一串字符串
var timeaxis = ['new Date(2016,11,1)'];
我想要的是[new Date(2016,11,1)]
如何在Thymeleaf中實現此目標?
我不能重現這個...在thymeleaf 3,我越來越:'VAR timeaxis = [新日期(2017,02,10),新日期(2017,02,10),新日期(2017,02,10)];'。你在使用百里香2嗎? – Metroids
@Metroids謝謝你的回答。我用的是thymeleaf 2.我也用thymleaf 3.0.1試過它,但它仍然不起作用。與thymeleaf 3我得到:'[{「年」:2016年,「月」:「11月」,「dayOfMonth」:1,「dayOfWeek」:「星期二」,「時代」:「CE」,「dayOfYear」:306 「leapYear」:真 「monthValue」:11 「年表」:{ 「ID」: 「ISO」, 「calendarType」: 「ISO8601」}}]' – leo