Example usage for com.google.gwt.i18n.client TimeZoneInfo buildTimeZoneData

List of usage examples for com.google.gwt.i18n.client TimeZoneInfo buildTimeZoneData

Introduction

In this page you can find the example usage for com.google.gwt.i18n.client TimeZoneInfo buildTimeZoneData.

Prototype

public static TimeZoneInfo buildTimeZoneData(String json) 

Source Link

Document

Construct a TimeZoneData javascript overlay object given some json text.

Usage

From source file:com.calclab.emite.core.client.xmpp.datetime.gwt.TimeZone.java

License:Open Source License

/**
 * This factory method creates a time zone instance from a JSON string that
 * contains the time zone information for desired time zone. Applications
 * can get such a string from the TimeZoneConstants class, or it can request
 * the string from the server. Either way, the application obtains the
 * original string from the data provided in the TimeZoneConstant.properties
 * file, which was carefully prepared from CLDR and Olson time zone
 * database.//w  w w .  j  a  v  a  2s. c  om
 * 
 * @param tzJSON
 *            JSON string that contains time zone data
 * @return a new time zone object
 */
public static TimeZone createTimeZone(String tzJSON) {
    TimeZoneInfo tzData = TimeZoneInfo.buildTimeZoneData(tzJSON);

    return createTimeZone(tzData);
}

From source file:com.vaadin.client.ui.datefield.AbstractTextualDateConnector.java

License:Apache License

@OnStateChange("timeZoneJSON")
private void onTimeZoneJSONChange() {
    TimeZone timeZone;//from   w  w w.j av  a  2 s.  c o m
    String timeZoneJSON = getState().timeZoneJSON;
    if (timeZoneJSON != null) {
        TimeZoneInfo timeZoneInfo = TimeZoneInfo.buildTimeZoneData(timeZoneJSON);
        timeZone = TimeZone.createTimeZone(timeZoneInfo);
    } else {
        timeZone = null;
    }
    getWidget().setTimeZone(timeZone);
}

From source file:gov.wa.wsdot.mobile.client.activities.ferries.schedules.departures.FerriesRouteDeparturesActivity.java

License:Open Source License

private void getFerryTerminalSailingSpaces(List<GenericRow> result) {
    if (result.size() != 0) {
        JSONValue value = JSONParser.parseStrict(
                result.get(0).getString(FerriesTerminalSailingSpaceColumns.TERMINAL_DEPARTING_SPACES));
        JSONArray departingSpaces = value.isArray();
        List<FerriesScheduleTimesItem> times = scheduleDateItems.get(view.getDayOfWeekSelected())
                .getFerriesTerminalItem().get(sailingsIndex).getScheduleTimes();
        DateTimeFormat dateFormat = DateTimeFormat.getFormat("MMMM d, yyyy h:mm a");
        final TimeZoneConstants timeZoneConstants = GWT.create(TimeZoneConstants.class);
        final TimeZone usPacific = TimeZone
                .createTimeZone(TimeZoneInfo.buildTimeZoneData(timeZoneConstants.americaLosAngeles()));

        for (int i = 0; i < departingSpaces.size(); i++) {
            JSONObject spaces = departingSpaces.get(i).isObject();
            String departure = dateFormat
                    .format(new Date(Long.parseLong(spaces.get("Departure").toString().substring(7, 20))));
            JSONArray spaceForArrivalTerminals = spaces.get("SpaceForArrivalTerminals").isArray();

            for (int j = 0; j < spaceForArrivalTerminals.size(); j++) {
                JSONObject terminals = spaceForArrivalTerminals.get(j).isObject();

                JSONArray arrivalTerminalIDs = terminals.get("ArrivalTerminalIDs").isArray();

                if (Integer.parseInt(terminals.get("TerminalID").toString()) == scheduleDateItems
                        .get(view.getDayOfWeekSelected()).getFerriesTerminalItem().get(sailingsIndex)
                        .getArrivingTerminalID()) {

                    JSONBoolean displayDriveUpSpace = terminals.get("DisplayDriveUpSpace").isBoolean();

                    boolean showIndicator = displayDriveUpSpace.booleanValue();
                    if (showIndicator) {
                        int driveUpSpaceCount = Integer.parseInt(terminals.get("DriveUpSpaceCount").toString());
                        int maxSpaceCount = Integer.parseInt(terminals.get("MaxSpaceCount").toString());

                        for (FerriesScheduleTimesItem time : times) {
                            if (dateFormat.format(new Date(Long.parseLong(time.getDepartingTime())))
                                    .equals(departure)) {
                                time.setDriveUpSpaceCount(driveUpSpaceCount);
                                time.setMaxSpaceCount(maxSpaceCount);
                                time.setLastUpdated(result.get(0)
                                        .getString(FerriesTerminalSailingSpaceColumns.TERMINAL_LAST_UPDATED));
                            }//  w ww  .j a  va 2  s.  c  o m
                        }
                    }
                }

                for (int k = 0; k < arrivalTerminalIDs.size(); k++) {
                    if (Integer.parseInt(arrivalTerminalIDs.get(k).toString()) != scheduleDateItems
                            .get(view.getDayOfWeekSelected()).getFerriesTerminalItem().get(sailingsIndex)
                            .getArrivingTerminalID()) {
                        continue;
                    } else {
                        JSONBoolean displayDriveUpSpace = terminals.get("DisplayDriveUpSpace").isBoolean();
                        boolean showIndicator = displayDriveUpSpace.booleanValue();
                        if (showIndicator) {
                            int driveUpSpaceCount = Integer
                                    .parseInt(terminals.get("DriveUpSpaceCount").toString());
                            int maxSpaceCount = Integer.parseInt(terminals.get("MaxSpaceCount").toString());

                            for (FerriesScheduleTimesItem time : times) {
                                if (dateFormat.format(new Date(Long.parseLong(time.getDepartingTime())))
                                        .equals(departure)) {
                                    time.setDriveUpSpaceCount(driveUpSpaceCount);
                                    time.setMaxSpaceCount(maxSpaceCount);
                                    time.setLastUpdated(result.get(0).getString(
                                            FerriesTerminalSailingSpaceColumns.TERMINAL_LAST_UPDATED));
                                }
                            }
                        }
                        k = arrivalTerminalIDs.size();
                    }
                }
            }
        }
    }

    view.hideProgressIndicator();
    view.render(scheduleDateItems.get(view.getDayOfWeekSelected()).getFerriesTerminalItem().get(sailingsIndex)
            .getScheduleTimes());
    view.refresh();
    accessibility.postScreenChangeNotification();

}

From source file:org.ssgwt.client.i18n.TimezoneLookupHelper.java

License:Apache License

/**
 * Adds a time zone info item to the lookup hash map
 *
 * @author Johannes Gryffenberg <johannes.gryffenberg@gmail.com>
 * @since  16 July 2016/*from  w  w  w  .java 2 s  .c  o m*/
 *
 * @param timezoneInfo - The time zone info details as retrieve from the SSTimeZoneConstants
 */
private void addTimeZoneInfo(String timezoneInfo) {
    TimeZoneInfo x = TimeZoneInfo.buildTimeZoneData(timezoneInfo);
    timeZoneInfos.put(x.getID(), x);
}