Example usage for java.util TimeZone getID

List of usage examples for java.util TimeZone getID

Introduction

In this page you can find the example usage for java.util TimeZone getID.

Prototype

public String getID() 

Source Link

Document

Gets the ID of this time zone.

Usage

From source file:com.oneis.javascript.Runtime.java

private static void checkJavaScriptTimeZoneIsGMT() {
    // Check that the timezone is GMT - datetime.js has created a Date object to run static initializers.
    // This is specific to the exact version of the Rhino implementation, but should fail gracefully if it's changed.
    boolean nativeDateTimeZoneOK = false;
    try {//from  www .j  a v  a 2s  .  co  m
        java.lang.Class nativeDate = java.lang.Class.forName("org.mozilla.javascript.NativeDate");
        java.lang.reflect.Field nativeDateTimeZoneField = nativeDate.getDeclaredField("thisTimeZone");
        nativeDateTimeZoneField.setAccessible(true);
        java.util.TimeZone tz = (java.util.TimeZone) nativeDateTimeZoneField.get(null);
        java.lang.reflect.Field nativeDateLocalTZAField = nativeDate.getDeclaredField("LocalTZA");
        nativeDateLocalTZAField.setAccessible(true);
        if (tz != null && (tz.getID().equals("GMT0") || tz.getID().equals("GMT") || tz.getID().equals("UTC"))
                && nativeDateLocalTZAField.getDouble(null) == 0.0) {
            nativeDateTimeZoneOK = true;
        }
    } catch (Exception e) {
        // Ignore, nativeDateTimeZoneOK won't be set to true.
    }
    if (!nativeDateTimeZoneOK) {
        System.out.println("\n\nThe operating system's time zone must be set to GMT (GMT0 Java TimeZone).\n");
        throw new RuntimeException("JavaScript interpreter's local time zone is not GMT (GMT0 Java TimeZone).");
    }
}

From source file:org.floggy.synchronization.jme.core.impl.JSONSerializationManager.java

/**
* DOCUMENT ME!/*from ww w . j a va 2 s . c  o  m*/
*
* @param value DOCUMENT ME!
* @param stringer DOCUMENT ME!
*
* @throws JSONException DOCUMENT ME!
*/
public static void toJSON(TimeZone value, JSONStringer stringer) throws JSONException {
    if (value == null) {
        stringer.value(null);
    } else {
        stringer.object();
        stringer.key("ID").value(value.getID());
        stringer.endObject();
    }
}

From source file:org.apache.falcon.entity.EntityUtil.java

public static TimeZone getTimeZone(String tzId) {
    if (tzId == null) {
        throw new IllegalArgumentException("Invalid TimeZone: Cannot be null.");
    }/*from w w w  . j  a  v a  2s .co m*/
    TimeZone tz = TimeZone.getTimeZone(tzId);
    if (!tzId.equals("GMT") && tz.getID().equals("GMT")) {
        throw new IllegalArgumentException("Invalid TimeZone: " + tzId);
    }
    return tz;
}

From source file:org.projectforge.web.wicket.converter.TimeZoneConverter.java

@Override
public String convertToString(final Object value, final Locale locale) {
    if (value == null) {
        return null;
    }//from w w w.jav a2s.co m
    final TimeZone timeZone = (TimeZone) value;
    return timeZone.getID() + " (" + timeZone.getDisplayName(locale) + ")";
}

From source file:org.bremersee.common.model.TimeZoneXmlAdapter.java

/**
 * Returns the ID of the time zone./*from  w w  w .  j  a va2s . c  om*/
 *
 * @param timeZone the time zone to marshal
 * @return the XML representation of the time zone
 * @throws Exception when parsing failed
 */
@Override
public String marshal(TimeZone timeZone) throws Exception {
    String s = timeZone != null ? timeZone.getID() : null;
    return StringUtils.isBlank(s) ? null : s;
}

From source file:org.projectforge.web.wicket.converter.TimeZoneConverter.java

@Override
public Object convertToObject(final String value, final Locale locale) {
    if (StringUtils.isEmpty(value) == true) {
        return null;
    }//  www.  j a  va 2 s.c  o m
    final int ind = value.indexOf(" (");
    final String id = ind >= 0 ? value.substring(0, ind) : value;
    final TimeZone timeZone = TimeZone.getTimeZone(id);
    if (timeZone.getID().toLowerCase(locale).equals(id.toLowerCase(locale)) == false) {
        error();
        return null;
    }
    return timeZone;
}

From source file:org.shredzone.cilla.admin.TimeZoneBean.java

@Override
public String getAsString(FacesContext fc, UIComponent uic, Object o) {
    try {/*  www .  j  a va 2s.com*/
        TimeZone tz = (TimeZone) o;
        return tz.getID();
    } catch (Exception ex) {
        throw new ConverterException(ex);
    }
}

From source file:nl.strohalm.cyclos.utils.conversion.TimeZoneConverter.java

public String toString(final TimeZone object) {
    if (object == null) {
        return null;
    }/*ww  w .j a  va2s . c  o m*/
    return object.getID();
}

From source file:org.codehaus.groovy.grails.web.binding.TimeZoneEditor.java

@Override
public String getAsText() {
    TimeZone tz = (TimeZone) getValue();
    if (tz == null) {
        return "";
    }//from   w  w  w. j av  a2s.  c o m

    return tz.getID();
}

From source file:groovyx.gaelyk.graelyk.cast.TimeZoneEditor.java

public String getAsText() {
    TimeZone tz = (TimeZone) getValue();
    if (tz == null) {
        return "";
    } else {/*from   w  w w.j  a va 2 s.co m*/
        return tz.getID();
    }
}