Example usage for com.vaadin.server WebBrowser getTimezoneOffset

List of usage examples for com.vaadin.server WebBrowser getTimezoneOffset

Introduction

In this page you can find the example usage for com.vaadin.server WebBrowser getTimezoneOffset.

Prototype

public int getTimezoneOffset() 

Source Link

Document

Returns the browser-reported TimeZone offset in milliseconds from GMT.

Usage

From source file:com.haulmont.cuba.web.AbstractConnection.java

License:Apache License

protected TimeZone detectTimeZone() {
    Page page = AppUI.getCurrent().getPage();
    WebBrowser webBrowser = page.getWebBrowser();

    int offset = webBrowser.getTimezoneOffset() / 1000 / 60;
    String hours = StringUtils.leftPad(String.valueOf(offset / 60), 2, '0');
    String mins = StringUtils.leftPad(String.valueOf(offset % 60), 2, '0');
    char sign = offset >= 0 ? '+' : '-';
    return TimeZone.getTimeZone("GMT" + sign + hours + mins);
}

From source file:com.haulmont.cuba.web.security.ConnectionImpl.java

License:Apache License

protected TimeZone detectTimeZone() {
    WebBrowser webBrowser = getWebBrowserDetails();

    int offset = webBrowser.getTimezoneOffset() / 1000 / 60;
    char sign = offset >= 0 ? '+' : '-';
    int absOffset = Math.abs(offset);

    String hours = StringUtils.leftPad(String.valueOf(absOffset / 60), 2, '0');
    String minutes = StringUtils.leftPad(String.valueOf(absOffset % 60), 2, '0');

    return TimeZone.getTimeZone("GMT" + sign + hours + minutes);
}