0

I am currently using smartGWT 4.1 in java to display UI element (dateItem) calendar to our clients

All the values(in java Date Object) are in UTC format. However, when passing into dateitem.setValue(date) Javascript from smartGWT auto translates the date value into local user browser timezone.

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?

I have tried pass the string value into the dateItem, but javascript will parse it back to date and the conversion will still happen. Also, I have tried DateUtil.setDefaultDisplayTimezone("00:00") but still nothing happens.

  • Have you tried using in `javascript` something like `yourDate.toUTCString()`? – leo.fcx Jul 31 '15 at 14:21
  • I have no access to javascript since we are writting everything in Java and everything will be complied into javascript. Our server is in EST and clients are worldwide, that's why I want all the dates in UTC format. Currently, if my dateItem value is set to 31-07-2015 23:59:59 UTC and the front end calendar will display 01-08-2015 (Toronto time) with time and hours removed. – Elvis Yuan Jul 31 '15 at 14:27

1 Answers1

0

did you try setting 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));
    }
});
claudiobosticco
  • 413
  • 2
  • 8