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);
}
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";
}
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";
}
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));
}
}
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));
}
Aggregations