XPages:使用浏览器的语言环境显示DateTime值 [英] XPages: display DateTime value using browser's locale
问题描述
我在绑定到文档数据源的XPage上有一些计算出的文本,然后尝试使用SSJS显示Notes DateTime字段的日期部分.
I've some computed text on an XPage bound to a document data source, and trying display the date component of a Notes DateTime field using SSJS.
我一直使用doc.getItemValueDateTimeArray方法,但是它似乎与服务器的语言环境有关(如果我将浏览器的语言从英国更改为美国,则日期格式仍为dd/mm/yyyy).
I've always used the doc.getItemValueDateTimeArray method, however it seems to be tied to the server's locale (if I change the browser's language from UK to US, the date format's still dd/mm/yyyy).
如何以符合浏览器语言设置的格式输出日期?
How do I output the date in a format that honours the browser's language setting?
推荐答案
尝试添加转换器(无需使用doc.getItemValueDateTimeArray即可直接显示数据源值):
Try adding a converter (that displays the data source value directly without using doc.getItemValueDateTimeArray):
<xp:text escape="true" id="computedField1" value="#{document1.dateField}">
<xp:this.converter>
<xp:convertDateTime type="date"></xp:convertDateTime>
</xp:this.converter>
</xp:text>
这篇关于XPages:使用浏览器的语言环境显示DateTime值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!