Example usage for java.util TimeZone setID

List of usage examples for java.util TimeZone setID

Introduction

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

Prototype

public void setID(String ID) 

Source Link

Document

Sets the time zone ID.

Usage

From source file:Main.java

public static void main(String args[]) {

    TimeZone tzone = TimeZone.getDefault();

    // set time zone ID
    tzone.setID("GMT+08:00");

    // checking time zone ID
    System.out.println("Time zone ID:" + tzone.getID());
}

From source file:com.trial.phonegap.plugin.calendar.CalendarAccessorGoogle.java

/**
 * Transforms a JSONObject object with information about an event in an event object
 * @param JsonEvent an JSONObject object with data about an event
 * @return an event object with te information within JSONObject object given by parameter
 * @throws JSONException//  w w  w. ja  va2 s  .  com
 */
private Event jsonEventToEvent(JSONObject jsonEvent) throws JSONException {

    Event event = new Event();

    if (!jsonEvent.isNull("id")) {
        event.setId(jsonEvent.getString("id"));
    }

    if (!jsonEvent.isNull("recurrence")) {
        Recurrence recurrence = new Recurrence();
        recurrence.setRule(parseJsonRecurrenceRule(jsonEvent.getJSONObject("recurrence")));
        if (!(jsonEvent.isNull("start")) && (!jsonEvent.isNull("end"))) {
            Dt dt = new Dt();
            dt.setDate(DateUtils.stringCalendarDateToDateLocale(jsonEvent.getString("start"),
                    "yyyy-MM-dd HH:mm:ss"));

            TimeZone tm = TimeZone.getDefault();
            tm.setID(Locale.getDefault().getISO3Country());

            dt.setTimeZone(tm.getDisplayName());
            recurrence.setDtStart(dt);
            dt.setDate(DateUtils.stringCalendarDateToDateLocale(jsonEvent.getString("end"),
                    "yyyy-MM-dd HH:mm:ss"));
            recurrence.setDtEnd(dt);
        }
        event.setRecurrence(recurrence);
    }

    if (!jsonEvent.isNull("description")) {
        event.setTitle(jsonEvent.getString("description"));
    }

    if (!jsonEvent.isNull("location")) {
        List<Where> whereList = new ArrayList<Where>();
        Where where = new Where();
        where.description = jsonEvent.getString("location");
        whereList.add(where);

        event.setWhere(whereList);
    }

    if (jsonEvent.isNull("summary"))
        event.setSummary(jsonEvent.getString("summary"));
    if (jsonEvent.isNull("status"))
        event.setEventStatus(constantSelector(jsonEvent.getString("status")));
    if (jsonEvent.isNull("transparency"))
        event.setTransparency(constantSelector(jsonEvent.getString("transparency")));

    if (jsonEvent.isNull("recurrence")) {
        List<When> whenList = new ArrayList<When>();
        When when = new When();
        if (!jsonEvent.isNull("start"))
            when.startTime = new DateTime(DateUtils.stringCalendarDateToDateLocale(jsonEvent.getString("start"),
                    "yyyy-MM-dd HH:mm:ss"));
        if (!jsonEvent.isNull("end"))
            when.endTime = new DateTime(DateUtils.stringCalendarDateToDateLocale(jsonEvent.getString("end"),
                    "yyyy-MM-dd HH:mm:ss"));
        if (!jsonEvent.isNull("reminder"))
            when.reminders = parseJsonReminder(jsonEvent.getString("reminder"));
        whenList.add(when);
        event.setWhen(whenList);
    }

    return event;

}