Example usage for com.vaadin.server WebBrowser getRawTimezoneOffset

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

Introduction

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

Prototype

public int getRawTimezoneOffset() 

Source Link

Document

Returns the browser-reported TimeZone offset in milliseconds from GMT ignoring possible daylight saving adjustments that may be in effect in the browser.

Usage

From source file:com.skysql.manager.DateConversion.java

License:Open Source License

/**
 * Instantiates a new date conversion./*from w  ww  .java 2  s.  com*/
 *
 * @param adjust adjust to local tz or not
 * @param format the output format
 */
public DateConversion(boolean adjust, String format) {
    this.adjust = adjust;
    this.format = (format == null ? DEFAULT_TIME_FORMAT : format);

    WebBrowser webBrowser = UI.getCurrent().getPage().getWebBrowser();
    int browserOffset = webBrowser.getRawTimezoneOffset();
    clientTimeZone = new SimpleTimeZone(browserOffset, "Client time zone");
    clientTZname = clientTimeZone.getDisplayName();
}

From source file:org.eclipse.hawkbit.ui.utils.SPDateTimeUtil.java

License:Open Source License

/**
 * Get browser time zone./*from  ww w  . jav  a 2  s.c o m*/
 *
 * @return TimeZone
 */
public static TimeZone getBrowserTimeZone() {
    final WebBrowser webBrowser = com.vaadin.server.Page.getCurrent().getWebBrowser();
    final String[] timeZones = TimeZone.getAvailableIDs(webBrowser.getRawTimezoneOffset());
    TimeZone tz = TimeZone.getDefault();
    for (final String string : timeZones) {
        final TimeZone t = TimeZone.getTimeZone(string);
        if (t.getRawOffset() == webBrowser.getRawTimezoneOffset()) {
            tz = t;
        }
    }
    return tz;
}