Search in sources :

Example 6 with DateTimeFormat

use of com.google.gwt.i18n.client.DateTimeFormat in project zxing by zxing.

the class CalendarEventGenerator method mergeDateAndTime.

private static Date mergeDateAndTime(Date date, Date time) {
    // Is that the only ugly way to do with GWT ? given that we don't
    // have java.util.Calendar for instance
    DateTimeFormat extractDate = DateTimeFormat.getFormat("yyyyMMdd");
    DateTimeFormat extractTime = DateTimeFormat.getFormat("HHmm");
    DateTimeFormat merger = DateTimeFormat.getFormat("yyyyMMddHHmmss");
    String d = extractDate.format(date);
    String t = extractTime.format(time) + "00";
    return merger.parse(d + t);
}
Also used : DateTimeFormat(com.google.gwt.i18n.client.DateTimeFormat)

Example 7 with DateTimeFormat

use of com.google.gwt.i18n.client.DateTimeFormat in project zxing by zxing.

the class CalendarEventGenerator method getDateTimeValues.

private String getDateTimeValues() throws GeneratorException {
    Date date1 = datePicker1.getValue();
    Date date2 = datePicker2.getValue();
    Date time1 = getDateFromTextBox(timePicker1);
    Date time2 = getDateFromTextBox(timePicker2);
    if (date1 == null || date2 == null || time1 == null || time2 == null) {
        throw new GeneratorException("Start and end dates/times must be set.");
    }
    String timezoneDelta = timeZones.getValue(timeZones.getSelectedIndex());
    long diffTimeZone = Long.parseLong(timezoneDelta);
    if (summerTime.getValue()) {
        diffTimeZone += ONE_HOUR;
    }
    Date dateTime1 = addMilliseconds(mergeDateAndTime(date1, time1), -diffTimeZone);
    Date dateTime2 = addMilliseconds(mergeDateAndTime(date2, time2), -diffTimeZone);
    if (dateTime1.after(dateTime2)) {
        throw new GeneratorException("Ending date/time cannot be before starting date/time.");
    }
    DateTimeFormat isoFormatter = DateTimeFormat.getFormat("yyyyMMdd'T'HHmmss'Z'");
    return "DTSTART:" + isoFormatter.format(dateTime1) + "\r\n" + "DTEND:" + isoFormatter.format(dateTime2) + "\r\n";
}
Also used : Date(java.util.Date) DateTimeFormat(com.google.gwt.i18n.client.DateTimeFormat)

Example 8 with DateTimeFormat

use of com.google.gwt.i18n.client.DateTimeFormat in project zxing by zxing.

the class CalendarEventGenerator method getFullDayDateFields.

private String getFullDayDateFields() throws GeneratorException {
    Date date1 = datePicker1.getValue();
    Date date2 = datePicker2.getValue();
    if (date1 == null || date2 == null) {
        throw new GeneratorException("Start and end dates must be set.");
    }
    if (date1.after(date2)) {
        throw new GeneratorException("End date cannot be before start date.");
    }
    // Specify end date as +1 day since it's exclusive
    Date date2PlusDay = new Date(date2.getTime() + 24 * 60 * 60 * 1000);
    DateTimeFormat isoFormatter = DateTimeFormat.getFormat("yyyyMMdd");
    return "DTSTART;VALUE=DATE:" + isoFormatter.format(date1) + "\r\n" + "DTEND;VALUE=DATE:" + isoFormatter.format(date2PlusDay) + "\r\n";
}
Also used : Date(java.util.Date) DateTimeFormat(com.google.gwt.i18n.client.DateTimeFormat)

Example 9 with DateTimeFormat

use of com.google.gwt.i18n.client.DateTimeFormat in project gerrit by GerritCodeReview.

the class Extras method setAnnotations.

public final void setAnnotations(JsArray<BlameInfo> blameInfos) {
    if (blameInfos.length() > 0) {
        setBlameInfo(blameInfos);
        JsArrayString gutters = ((JsArrayString) JsArrayString.createArray());
        gutters.push(ANNOTATION_GUTTER_ID);
        cm.setOption("gutters", gutters);
        annotated = true;
        DateTimeFormat format = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_SHORT);
        JsArray<LintLine> annotations = JsArray.createArray().cast();
        for (BlameInfo blameInfo : Natives.asList(blameInfos)) {
            for (RangeInfo range : Natives.asList(blameInfo.ranges())) {
                Date commitTime = new Date(blameInfo.time() * 1000L);
                String shortId = blameInfo.id().substring(0, 8);
                String shortBlame = C.shortBlameMsg(shortId, format.format(commitTime), blameInfo.author());
                String detailedBlame = C.detailedBlameMsg(blameInfo.id(), blameInfo.author(), FormatUtil.mediumFormat(commitTime), blameInfo.commitMsg());
                annotations.push(LintLine.create(shortBlame, detailedBlame, shortId, Pos.create(range.start() - 1)));
            }
        }
        cm.setOption("lint", getAnnotation(annotations));
    }
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString) RangeInfo(com.google.gerrit.client.RangeInfo) JsArrayString(com.google.gwt.core.client.JsArrayString) Date(java.util.Date) DateTimeFormat(com.google.gwt.i18n.client.DateTimeFormat) BlameInfo(com.google.gerrit.client.blame.BlameInfo)

Example 10 with DateTimeFormat

use of com.google.gwt.i18n.client.DateTimeFormat in project gerrit by GerritCodeReview.

the class MyOAuthTokenScreen method getExpiresAt.

private static String getExpiresAt(OAuthTokenInfo tokenInfo, GeneralPreferences prefs) {
    long expiresAt = getExpiresAt(tokenInfo);
    if (expiresAt == Long.MAX_VALUE) {
        return "";
    }
    String dateFormat = prefs.dateFormat().getLongFormat();
    String timeFormat = prefs.timeFormat().getFormat();
    DateTimeFormat formatter = DateTimeFormat.getFormat(dateFormat + " " + timeFormat);
    return formatter.format(new Date(expiresAt));
}
Also used : Date(java.util.Date) DateTimeFormat(com.google.gwt.i18n.client.DateTimeFormat)

Aggregations

DateTimeFormat (com.google.gwt.i18n.client.DateTimeFormat)12 Date (java.util.Date)6 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)2 FieldEvent (com.extjs.gxt.ui.client.event.FieldEvent)1 DateWrapper (com.extjs.gxt.ui.client.util.DateWrapper)1 LabelToolItem (com.extjs.gxt.ui.client.widget.toolbar.LabelToolItem)1 RangeInfo (com.google.gerrit.client.RangeInfo)1 BlameInfo (com.google.gerrit.client.blame.BlameInfo)1 JsArrayString (com.google.gwt.core.client.JsArrayString)1 TableCellElement (com.google.gwt.dom.client.TableCellElement)1 Request (com.google.gwt.http.client.Request)1 RequestBuilder (com.google.gwt.http.client.RequestBuilder)1 RequestCallback (com.google.gwt.http.client.RequestCallback)1 RequestException (com.google.gwt.http.client.RequestException)1 Response (com.google.gwt.http.client.Response)1 JSONObject (com.google.gwt.json.client.JSONObject)1 JSONString (com.google.gwt.json.client.JSONString)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 AbstractHeaderOrFooterBuilder (com.google.gwt.user.cellview.client.AbstractHeaderOrFooterBuilder)1