Example usage for org.joda.time DateTimeZone forTimeZone

List of usage examples for org.joda.time DateTimeZone forTimeZone

Introduction

In this page you can find the example usage for org.joda.time DateTimeZone forTimeZone.

Prototype

public static DateTimeZone forTimeZone(TimeZone zone) 

Source Link

Document

Gets a time zone instance for a JDK TimeZone.

Usage

From source file:org.flockdata.model.Entity.java

License:Open Source License

@JsonIgnore // Don't persist ov
public DateTime getFortressUpdatedTz() {
    if (fortressLastWhen == null)
        return null;
    return new DateTime(fortressLastWhen,
            DateTimeZone.forTimeZone(TimeZone.getTimeZone(segment.getFortress().getTimeZone())));
}

From source file:org.flockdata.model.EntityLog.java

License:Open Source License

public EntityLog(Entity entity, Log log, DateTime fortressWhen) {
    this();/*from   w  w  w.j a v  a 2s  .c  o  m*/
    this.entity = entity;
    this.log = log;
    this.timezone = entity.getSegment().getFortress().getTimeZone();
    if (entity.getSegment().getFortress().isStoreDisabled()) {
        id = 0l;
        isMock = log.isMocked();
    }
    if (fortressWhen != null && fortressWhen.getMillis() != 0) {
        setFortressWhen(fortressWhen);
    } else {
        // "now" in the fortress default timezone
        setFortressWhen(new DateTime(sysWhen, DateTimeZone
                .forTimeZone(TimeZone.getTimeZone(entity.getSegment().getFortress().getTimeZone()))));
    }
    log.setEntityLog(this);
}

From source file:org.flowable.cmmn.engine.impl.behavior.impl.TimerEventListenerActivityBehaviour.java

License:Apache License

public String prepareRepeat(String dueDate, Clock clock) {
    if (dueDate.startsWith("R") && dueDate.split("/").length == 2) {
        DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
        return dueDate.replace("/", "/" + fmt.print(
                new DateTime(clock.getCurrentTime(), DateTimeZone.forTimeZone(clock.getCurrentTimeZone())))
                + "/");
    }/*  w  w  w .j  ava2 s  .  c o  m*/
    return dueDate;
}

From source file:org.flowable.common.engine.impl.calendar.BusinessCalendarImpl.java

License:Apache License

@Override
public Date resolveEndDate(String endDateString) {
    return ISODateTimeFormat.dateTimeParser()
            .withZone(DateTimeZone.forTimeZone(clockReader.getCurrentTimeZone())).parseDateTime(endDateString)
            .toCalendar(null).getTime();
}

From source file:org.flowable.common.engine.impl.calendar.DurationHelper.java

License:Apache License

protected Calendar parseDate(String date) throws Exception {
    Calendar dateCalendar = null;
    try {//from   ww  w .  j  av  a 2s. c o  m
        dateCalendar = ISODateTimeFormat.dateTimeParser()
                .withZone(DateTimeZone.forTimeZone(clockReader.getCurrentTimeZone())).parseDateTime(date)
                .toCalendar(null);

    } catch (IllegalArgumentException e) {
        // try to parse a java.util.date to string back to a java.util.date
        dateCalendar = new GregorianCalendar();
        dateCalendar.setTime(DATE_FORMAT.parse(date));
    }

    return dateCalendar;
}

From source file:org.gdg.frisbee.android.api.GoogleDevelopersLive.java

License:Apache License

public ApiRequest getRecordedShows(String category, Response.Listener<GdlShowList> successListener,
        Response.ErrorListener errorListener) {

    if (category == null || category.equals("")) {
        category = "";
    } else {/*from w  w w. j a  v  a  2  s .  co m*/
        category = "/" + category;
    }
    JsoupRequest<GdlShowList> dirReq = new JsoupRequest<GdlShowList>(Request.Method.POST,
            BASE_URL + String.format(RECORDED_SHOWS, category), new JsoupRequest.ParseListener<GdlShowList>() {
                @Override
                public GdlShowList parse(Document doc) {

                    Element nextToken = doc.select("div.paging-cursor").first();

                    GdlShowList showList;

                    if (nextToken != null)
                        showList = new GdlShowList(nextToken.attr("data-cursor"));
                    else
                        showList = new GdlShowList(null);

                    Elements shows = doc.select("li");
                    Pattern p = Pattern.compile(".*i\\.ytimg\\.com/vi/([^/]+).*");
                    DateTimeFormatter fmt = DateTimeFormat.forPattern("MMMM d, YYYY, h:mm")
                            .withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone("America/Los_Angeles")));

                    for (int i = 0; i < shows.size(); i++) {
                        Element show = shows.get(i);
                        Element showLink = show.select("a").first();

                        GdlShow gdlShow = new GdlShow();
                        if (showLink != null) {
                            gdlShow.setTitle(showLink.text());

                            /*String dateTime = show.text()
                                    .replace(showLink.text(), "")
                                    .replace("a.m.", "")
                                    .replace("p.m.", "")
                                    .trim();
                            gdlShow.setDateTime(fmt.parseDateTime(dateTime).toDateTime(DateTimeZone.getDefault()));*/
                            gdlShow.setUrl(showLink.attr("href"));
                            String thumbLink = showLink.select("img.video-thumbnail").first().attr("src");
                            Matcher matcher = p.matcher(thumbLink);
                            if (matcher.matches()) {
                                gdlShow.setYoutubeId(matcher.group(1));
                            }
                        }
                        showList.getShows().add(gdlShow);
                    }

                    return showList; //To change body of implemented methods use File | Settings | File Templates.
                }
            }, successListener, errorListener);
    return new ApiRequest(dirReq);
}

From source file:org.gephi.desktop.datalab.ConfigurationPanel.java

License:Open Source License

/**
 * Creates new form ConfigurationPanel//ww  w.  j  a v  a 2s  .c o  m
 */
public ConfigurationPanel(final DataTableTopComponent dataTableTopComponent, final GraphModel graphModel) {
    this.dataTableTopComponent = dataTableTopComponent;
    this.graphModel = graphModel;
    initComponents();

    for (TimeFormat tf : TimeFormat.values()) {
        timeFormatComboBox.addItem(new TimeFormatWrapper(tf));
    }
    timeFormatComboBox.setSelectedItem(new TimeFormatWrapper(graphModel.getTimeFormat()));

    timeFormatComboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            graphModel.setTimeFormat(((TimeFormatWrapper) timeFormatComboBox.getSelectedItem()).timeFormat);
            dataTableTopComponent.refreshCurrentTable();
        }
    });

    onlyVisibleCheckBox.setSelected(dataTableTopComponent.isShowOnlyVisible());
    useSparklinesCheckBox.setSelected(dataTableTopComponent.isUseSparklines());
    timeIntervalsGraphicsCheckBox.setSelected(dataTableTopComponent.isTimeIntervalGraphics());
    showEdgesNodesLabelsCheckBox.setSelected(dataTableTopComponent.isShowEdgesNodesLabels());

    //Timezone:
    long currentTimestamp = System.currentTimeMillis();
    DateTimeZone currentTimeZone = graphModel.getTimeZone();

    buildTimeZoneList();
    timeZoneComboBox.setSelectedItem(new TimeZoneWrapper(currentTimeZone.toTimeZone(), currentTimestamp));

    timeZoneComboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            TimeZone selected = ((TimeZoneWrapper) timeZoneComboBox.getSelectedItem()).timeZone;
            graphModel.setTimeZone(DateTimeZone.forTimeZone(selected));
            dataTableTopComponent.refreshCurrentTable();
        }
    });

    //Time representation:
    for (TimeRepresentation tr : TimeRepresentation.values()) {
        timeRepresentationComboBox.addItem(new TimeRepresentationWrapper(tr));
    }
    timeRepresentationComboBox.setSelectedItem(
            new TimeRepresentationWrapper(graphModel.getConfiguration().getTimeRepresentation()));

    if (canChangeTimeRepresentation(graphModel)) {
        timeRepresentationComboBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                Configuration c = graphModel.getConfiguration();
                c.setTimeRepresentation(((TimeRepresentationWrapper) timeRepresentationComboBox
                        .getSelectedItem()).timeRepresentation);
                graphModel.setConfiguration(c);
            }
        });
    } else {
        timeRepresentationComboBox.setEnabled(false);
        timeRepresentationComboBox.setToolTipText(NbBundle.getMessage(ConfigurationPanel.class,
                "ConfigurationPanel.timeRepresentation.disabled.tooltip"));
    }
}

From source file:org.hippoecm.frontend.plugins.yui.datetime.YuiDateTimeField.java

License:Apache License

private void updateDateTime() {
    Date date = getDate();//w w w  .j  ava  2  s . c o  m
    if (date != null) {
        MutableDateTime datetime = new MutableDateTime(date);
        try {
            TimeZone zone = getClientTimeZone();
            if (zone != null) {
                datetime.setZone(DateTimeZone.forTimeZone(zone));
            }

            Integer hours = getHours();
            if (hours != null) {
                datetime.set(DateTimeFieldType.hourOfDay(), hours % 24);

                Integer minutes = getMinutes();
                datetime.setMinuteOfHour(minutes != null ? minutes : 0);
            }

            // the date will be in the server's timezone
            setDate(datetime.toDate());
            //setModelObject(datetime.toDate());
        } catch (RuntimeException e) {
            error(e.getMessage());
            invalid();
        }
    }
}

From source file:org.hippoecm.frontend.widgets.AjaxDateTimeField.java

License:Apache License

private void updateDateTime(Object datetime, Integer hours, Integer minutes, AjaxRequestTarget target) {
    MutableDateTime date = new MutableDateTime(datetime);
    try {/*from w w  w .j  av a2s  . co m*/
        TimeZone zone = getClientTimeZone();
        if (zone != null) {
            date.setZone(DateTimeZone.forTimeZone(zone));
        }

        if (hours != null) {
            date.set(DateTimeFieldType.hourOfDay(), hours.intValue() % 24);
            date.setMinuteOfHour((minutes != null) ? minutes.intValue() : 0);
        }

        // the date will be in the server's timezone
        setModelObject(date.toDate());

        if (target != null) {
            target.add(this);
        }
    } catch (RuntimeException e) {
        error(e.getMessage());
        invalid();
    }
}

From source file:org.housecream.solar.SolarAdvancedCalculator.java

License:Open Source License

public SolarAdvancedCalculator(double latitude, double longitude, TimeZone timezone) {
    this.latitude = latitude;
    this.longitude = longitude;
    this.timezone = DateTimeZone.forTimeZone(timezone);
}