简体   繁体   English

smartGWT中的DateItem自动将UTC日期转换为Javascript中的本地客户端浏览器日期

[英]DateItem in smartGWT auto translate UTC date to local client browser date in Javascript

I am currently using smartGWT 4.1 in java to display UI element (dateItem) calendar to our clients 我目前在Java中使用smartGWT 4.1向用户显示UI元素(dateItem)日历

All the values(in java Date Object) are in UTC format. 所有值(在Java Date Object中)均为UTC格式。 However, when passing into dateitem.setValue(date) Javascript from smartGWT auto translates the date value into local user browser timezone. 但是,当传入dateitem.setValue(date)时,来自smartGWT的Javascript会自动将日期值转换为本地用户浏览器时区。

Since I need all the dates presented on the UI in the UTC format, is there any way to disable smartGWT (or javascript) auto translation? 由于我需要使用UTC格式在UI上显示的所有日期,因此有什么方法可以禁用smartGWT(或javascript)自动翻译吗?

I have tried pass the string value into the dateItem, but javascript will parse it back to date and the conversion will still happen. 我试过将字符串值传递给dateItem,但是javascript会将其解析回日期,并且转换仍然会发生。 Also, I have tried DateUtil.setDefaultDisplayTimezone("00:00") but still nothing happens. 另外,我尝试了DateUtil.setDefaultDisplayTimezone(“ 00:00”),但仍然没有任何反应。

did you try setting setShortDateDisplayFormatter: 您是否尝试设置setShortDateDisplayFormatter:

DateUtil.setShortDateDisplayFormatter(new DateDisplayFormatter() {
    public String format(Date date) {
        if(date == null) {
            return null;
        }
        DateTimeFormat dateFormatter = DateTimeFormat.getFormat("dd-MM-yyyy"+ "T"+"HH:mm:ss");
        return dateFormatter.format(date, TimeZone.createTimeZone(0));
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM