Java Code Examples for com.google.gwt.i18n.shared.DateTimeFormat#getFormat()

The following examples show how to use com.google.gwt.i18n.shared.DateTimeFormat#getFormat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubaTimeFieldWidget.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected boolean isValueParsable(String time) {
    if (nullRepresentation.equals(time)) {
        return true;
    }

    if (timeFormat == null || timeFormat.isEmpty()) {
        // let server side to parse
        return true;
    }

    DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat(timeFormat);
    try {
        dateTimeFormat.parseStrict(time);
        return true;
    } catch (Exception e) {
        return false;
    }
}
 
Example 2
Source File: TimelineWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
private long adjustToMiddleOfDay(long zonedDate) {
    DateTimeFormat hourFormat = DateTimeFormat.getFormat("HH");
    String hourStr = hourFormat.format(new Date(zonedDate), getLocaleDataProvider().getTimeZone());
    int h = Integer.parseInt(hourStr);
    int addHours = 12 - h;
    return zonedDate + (addHours * HOUR_INTERVAL);
}
 
Example 3
Source File: TimelineWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
public DateTimeFormat getYearDateTimeFormat() {
    if (yearDateTimeFormat == null) {
        yearDateTimeFormat = DateTimeFormat.getFormat("yyyy");
    }
    return yearDateTimeFormat;
}
 
Example 4
Source File: TimelineWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
public DateTimeFormat getMonthDateTimeFormat() {
    if (monthDateTimeFormat == null) {
        monthDateTimeFormat = DateTimeFormat.getFormat("M");
    }
    return monthDateTimeFormat;
}
 
Example 5
Source File: TimelineWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
public DateTimeFormat getWeekDateTimeFormat() {
    if (weekDateTimeFormat == null) {
        weekDateTimeFormat = DateTimeFormat.getFormat("d");
    }
    return weekDateTimeFormat;
}
 
Example 6
Source File: TimelineWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
public DateTimeFormat getDayDateTimeFormat() {
    if (dayDateTimeFormat == null) {
        dayDateTimeFormat = DateTimeFormat.getFormat("d");
    }
    return dayDateTimeFormat;
}
 
Example 7
Source File: TimelineWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
public DateTimeFormat getHour12DateTimeFormat() {
    if (hour12DateTimeFormat == null) {
        hour12DateTimeFormat = DateTimeFormat.getFormat("h");
    }
    return hour12DateTimeFormat;
}
 
Example 8
Source File: TimelineWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
public DateTimeFormat getHour24DateTimeFormat() {
    if (hour24DateTimeFormat == null) {
        hour24DateTimeFormat = DateTimeFormat.getFormat("HH");
    }
    return hour24DateTimeFormat;
}
 
Example 9
Source File: TimelineWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
public DateTimeFormat getCustomHourDateTimeFormat() {
    if (customHourDateTimeFormat == null) {
        customHourDateTimeFormat = DateTimeFormat.getFormat(hourFormat);
    }
    return customHourDateTimeFormat;
}