Example usage for com.google.gwt.i18n.shared DefaultDateTimeFormatInfo DefaultDateTimeFormatInfo

List of usage examples for com.google.gwt.i18n.shared DefaultDateTimeFormatInfo DefaultDateTimeFormatInfo

Introduction

In this page you can find the example usage for com.google.gwt.i18n.shared DefaultDateTimeFormatInfo DefaultDateTimeFormatInfo.

Prototype

DefaultDateTimeFormatInfo

Source Link

Usage

From source file:com.google.gwt.sample.stockwatcher.server.CurrencyServiceImpl.java

private String calculateRatesUrl() {
    String pattern = "yyyy-MM-dd";
    DefaultDateTimeFormatInfo info = new DefaultDateTimeFormatInfo();
    DateTimeFormat dtf = new DateTimeFormat(pattern, info) {
    };//ww w .j a  va  2 s. com
    Date d = new Date();
    CalendarUtil.addMonthsToDate(d, -1);
    return "http://api.fixer.io/" + dtf.format(d) + "?base=HKD";
}

From source file:com.rnb.plategka.shared.DateTimeFormat.java

License:Apache License

/**
 * Get a DateTimeFormat instance for a predefined format.
 * /*from ww w.ja v a  2s  .c  om*/
 * <p>
 * See {@link CustomDateTimeFormat} if you need a localized format that is
 * not supported here.
 * 
 * @param predef
 *            {@link PredefinedFormat} describing desired format
 * @return a DateTimeFormat instance for the specified format
 */
public static DateTimeFormat getFormat(PredefinedFormat predef) {
    if (usesFixedEnglishStrings(predef)) {
        String pattern;
        switch (predef) {
        case RFC_2822:
            pattern = RFC2822_PATTERN;
            break;
        case ISO_8601:
            pattern = ISO8601_PATTERN;
            break;
        default:
            throw new IllegalStateException("Unexpected predef type " + predef);
        }
        return getFormat(pattern, new DefaultDateTimeFormatInfo());
    }
    DateTimeFormatInfo dtfi = getDefaultDateTimeFormatInfo();
    String pattern;
    switch (predef) {
    case DATE_FULL:
        pattern = dtfi.dateFormatFull();
        break;
    case DATE_LONG:
        pattern = dtfi.dateFormatLong();
        break;
    case DATE_MEDIUM:
        pattern = dtfi.dateFormatMedium();
        break;
    case DATE_SHORT:
        pattern = dtfi.dateFormatShort();
        break;
    case DATE_TIME_FULL:
        pattern = dtfi.dateTimeFull(dtfi.timeFormatFull(), dtfi.dateFormatFull());
        break;
    case DATE_TIME_LONG:
        pattern = dtfi.dateTimeLong(dtfi.timeFormatLong(), dtfi.dateFormatLong());
        break;
    case DATE_TIME_MEDIUM:
        pattern = dtfi.dateTimeMedium(dtfi.timeFormatMedium(), dtfi.dateFormatMedium());
        break;
    case DATE_TIME_SHORT:
        pattern = dtfi.dateTimeShort(dtfi.timeFormatShort(), dtfi.dateFormatShort());
        break;
    case DAY:
        pattern = dtfi.formatDay();
        break;
    case HOUR24_MINUTE:
        pattern = dtfi.formatHour24Minute();
        break;
    case HOUR24_MINUTE_SECOND:
        pattern = dtfi.formatHour24MinuteSecond();
        break;
    case HOUR_MINUTE:
        pattern = dtfi.formatHour12Minute();
        break;
    case HOUR_MINUTE_SECOND:
        pattern = dtfi.formatHour12MinuteSecond();
        break;
    case MINUTE_SECOND:
        pattern = dtfi.formatMinuteSecond();
        break;
    case MONTH:
        pattern = dtfi.formatMonthFull();
        break;
    case MONTH_ABBR:
        pattern = dtfi.formatMonthAbbrev();
        break;
    case MONTH_ABBR_DAY:
        pattern = dtfi.formatMonthAbbrevDay();
        break;
    case MONTH_DAY:
        pattern = dtfi.formatMonthFullDay();
        break;
    case MONTH_NUM_DAY:
        pattern = dtfi.formatMonthNumDay();
        break;
    case MONTH_WEEKDAY_DAY:
        pattern = dtfi.formatMonthFullWeekdayDay();
        break;
    case TIME_FULL:
        pattern = dtfi.timeFormatFull();
        break;
    case TIME_LONG:
        pattern = dtfi.timeFormatLong();
        break;
    case TIME_MEDIUM:
        pattern = dtfi.timeFormatMedium();
        break;
    case TIME_SHORT:
        pattern = dtfi.timeFormatShort();
        break;
    case YEAR:
        pattern = dtfi.formatYear();
        break;
    case YEAR_MONTH:
        pattern = dtfi.formatYearMonthFull();
        break;
    case YEAR_MONTH_ABBR:
        pattern = dtfi.formatYearMonthAbbrev();
        break;
    case YEAR_MONTH_ABBR_DAY:
        pattern = dtfi.formatYearMonthAbbrevDay();
        break;
    case YEAR_MONTH_DAY:
        pattern = dtfi.formatYearMonthFullDay();
        break;
    case YEAR_MONTH_NUM:
        pattern = dtfi.formatYearMonthNum();
        break;
    case YEAR_MONTH_NUM_DAY:
        pattern = dtfi.formatYearMonthNumDay();
        break;
    case YEAR_MONTH_WEEKDAY_DAY:
        pattern = dtfi.formatYearMonthWeekdayDay();
        break;
    case YEAR_QUARTER:
        pattern = dtfi.formatYearQuarterFull();
        break;
    case YEAR_QUARTER_ABBR:
        pattern = dtfi.formatYearQuarterShort();
        break;
    default:
        throw new IllegalArgumentException("Unexpected predefined format " + predef);
    }
    return getFormat(pattern, dtfi);
}

From source file:com.rnb.plategka.shared.DateTimeFormat.java

License:Apache License

private static DateTimeFormatInfo getDefaultDateTimeFormatInfo() {
    // MUSTFIX(jat): implement
    //return LocaleInfo.getCurrentLocale().getDateTimeFormatInfo();
    // The previous line caused
    // "java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client code!"
    // when using DateTimeFormat in the server-side code.
    // DefaultDateTimeFormatInfo is part of the shared package - don't really know what the difference is but it does the trick for me.
    return new DefaultDateTimeFormatInfo();
}

From source file:edu.stanford.isis.epad.plugin.lesiontracking.shared.DateTimeFormat.java

License:Apache License

private static DateTimeFormatInfo getDefaultDateTimeFormatInfo() {
    return new DefaultDateTimeFormatInfo();
}

From source file:org.openelis.scriptlet.ms.conf.Scriptlet.java

License:Open Source License

public Scriptlet(ScriptletProxy proxy, Integer analysisId) {
    this.proxy = proxy;
    this.analysisId = analysisId;

    proxy.log(Level.FINE, "Initializing MSConfScriptlet1", null);
    try {//from ww  w  .j a va  2s .  com
        if (!initialized) {
            initialized = true;
            YES = proxy.getDictionaryBySystemName("yes").getId();
            UNIT_MM = proxy.getDictionaryBySystemName("millimeters").getId();
            UNIT_YEARS = proxy.getDictionaryBySystemName("years_local").getId();
            GEST_AGE_LMP = proxy.getDictionaryBySystemName("gest_age_date_type_lmp").getId();
            GEST_AGE_US = proxy.getDictionaryBySystemName("gest_age_date_type_us").getId();
            INT_POSITIVE = proxy.getDictionaryBySystemName("positive").getId();
            INT_NEGATIVE = proxy.getDictionaryBySystemName("negative").getId();
            ACTION_SEE_ACHE = proxy.getDictionaryBySystemName("ms_rec_action_see_ache_res").getId();
            ACTION_NO_ACTION = proxy.getDictionaryBySystemName("ms_rec_action_no_action").getId();
            YES_STR = YES.toString();

            /*
             * the formatter that converts from string to date
             */
            dateFormatter = new DateTimeFormat(Messages.get().datePattern(), new DefaultDateTimeFormatInfo()) {
            };
        }
        proxy.log(Level.FINE, "Initialized MSConfScriptlet1", null);
    } catch (Exception e) {
        initialized = false;
        proxy.log(Level.SEVERE, "Failed to initialize dictionary constants", e);
    }
}

From source file:org.openelis.scriptlet.ms.firstInteg.Scriptlet.java

License:Open Source License

public Scriptlet(ScriptletProxy proxy, Integer analysisId) {
    this.proxy = proxy;
    this.analysisId = analysisId;

    proxy.log(Level.FINE, "Initializing MS1stIntegScriptlet1", null);
    try {/*ww  w  .j a  va 2  s. c om*/
        if (!initialized) {
            initialized = true;
            YES = proxy.getDictionaryBySystemName("yes").getId();
            UNIT_MM = proxy.getDictionaryBySystemName("millimeters").getId();
            UNIT_POUNDS = proxy.getDictionaryBySystemName("pounds_local").getId();
            UNIT_YEARS = proxy.getDictionaryBySystemName("years_local").getId();
            INT_POSITIVE = proxy.getDictionaryBySystemName("positive").getId();
            INT_NEGATIVE = proxy.getDictionaryBySystemName("negative").getId();
            INT_UNKNOWN = proxy.getDictionaryBySystemName("unknown").getId();
            ACTION_US_DIAG = proxy.getDictionaryBySystemName("ms_rec_action_us_diag").getId();
            ACTION_NO_ACTION = proxy.getDictionaryBySystemName("ms_rec_action_no_action").getId();
            ACTION_RISK_NOT_CALC = proxy.getDictionaryBySystemName("ms_rec_action_risk_not_calc").getId();
            YES_STR = YES.toString();

            /*
             * the formatter that converts from string to date
             */
            dateFormatter = new DateTimeFormat(Messages.get().datePattern(), new DefaultDateTimeFormatInfo()) {
            };
        }
        proxy.log(Level.FINE, "Initialized MS1stIntegScriptlet1", null);
    } catch (Exception e) {
        initialized = false;
        proxy.log(Level.SEVERE, "Failed to initialize dictionary constants", e);
    }
}

From source file:org.openelis.scriptlet.ms.firstTri.Scriptlet.java

License:Open Source License

public Scriptlet(ScriptletProxy proxy, Integer analysisId) {
    this.proxy = proxy;
    this.analysisId = analysisId;

    proxy.log(Level.FINE, "Initializing MS1stTriScriptlet1", null);
    try {/*from  ww  w .j av a  2 s. c  om*/
        if (!initialized) {
            initialized = true;
            YES = proxy.getDictionaryBySystemName("yes").getId();
            UNIT_MM = proxy.getDictionaryBySystemName("millimeters").getId();
            UNIT_POUNDS = proxy.getDictionaryBySystemName("pounds_local").getId();
            UNIT_YEARS = proxy.getDictionaryBySystemName("years_local").getId();
            INT_POSITIVE = proxy.getDictionaryBySystemName("positive").getId();
            INT_NEGATIVE = proxy.getDictionaryBySystemName("negative").getId();
            INT_UNKNOWN = proxy.getDictionaryBySystemName("unknown").getId();
            ACTION_US_DIAG = proxy.getDictionaryBySystemName("ms_rec_action_us_diag").getId();
            ACTION_NO_ACTION = proxy.getDictionaryBySystemName("ms_rec_action_no_action").getId();
            ACTION_RISK_NOT_CALC = proxy.getDictionaryBySystemName("ms_rec_action_risk_not_calc").getId();
            YES_STR = YES.toString();

            /*
             * the formatter that converts from string to date
             */
            dateFormatter = new DateTimeFormat(Messages.get().datePattern(), new DefaultDateTimeFormatInfo()) {
            };
        }
        proxy.log(Level.FINE, "Initialized MS1stTriScriptlet1", null);
    } catch (Exception e) {
        initialized = false;
        proxy.log(Level.SEVERE, "Failed to initialize dictionary constants", e);
    }
}

From source file:org.openelis.scriptlet.ms.integrate.Scriptlet.java

License:Open Source License

public Scriptlet(ScriptletProxy proxy, Integer analysisId) {
    this.proxy = proxy;
    this.analysisId = analysisId;

    proxy.log(Level.FINE, "Initializing MSIntegrateScriptlet1", null);
    try {//from w w  w  .j av  a2 s.  com
        if (!initialized) {
            initialized = true;
            YES = proxy.getDictionaryBySystemName("yes").getId();
            NO = proxy.getDictionaryBySystemName("no").getId();
            UNIT_MM = proxy.getDictionaryBySystemName("millimeters").getId();
            UNIT_POUNDS = proxy.getDictionaryBySystemName("pounds_local").getId();
            UNIT_YEARS = proxy.getDictionaryBySystemName("years_local").getId();
            INT_POSITIVE = proxy.getDictionaryBySystemName("positive").getId();
            INT_NEGATIVE = proxy.getDictionaryBySystemName("negative").getId();
            INT_UNKNOWN = proxy.getDictionaryBySystemName("unknown").getId();
            ACTION_US_AMN = proxy.getDictionaryBySystemName("ms_rec_action_us_amn").getId();
            ACTION_US_DIAG = proxy.getDictionaryBySystemName("ms_rec_action_us_diag").getId();
            ACTION_NO_ACTION = proxy.getDictionaryBySystemName("ms_rec_action_no_action").getId();
            ACTION_RISK_NOT_CALC = proxy.getDictionaryBySystemName("ms_rec_action_risk_not_calc").getId();
            YES_STR = YES.toString();
            RACE_BLACK_STR = proxy.getDictionaryBySystemName("race_b").getId().toString();

            /*
             * the formatters that convert from string to date or vice-versa
             */
            dateFormatter = new DateTimeFormat(Messages.get().datePattern(), new DefaultDateTimeFormatInfo()) {
            };
            dateTimeFormatter = new DateTimeFormat(Messages.get().dateTimePattern(),
                    new DefaultDateTimeFormatInfo()) {
            };
        }
        proxy.log(Level.FINE, "Initialized MSIntegrateScriptlet1", null);
    } catch (Exception e) {
        initialized = false;
        proxy.log(Level.SEVERE, "Failed to initialize dictionary constants", e);
    }
}

From source file:org.openelis.scriptlet.ms.ntd.Scriptlet.java

License:Open Source License

public Scriptlet(ScriptletProxy proxy, Integer analysisId) {
    this.proxy = proxy;
    this.analysisId = analysisId;

    proxy.log(Level.FINE, "Initializing MSNTDScriptlet1", null);
    try {/*from   w  ww .  ja va 2 s.c o m*/
        if (!initialized) {
            initialized = true;
            YES = proxy.getDictionaryBySystemName("yes").getId();
            NO = proxy.getDictionaryBySystemName("no").getId();
            UNIT_MM = proxy.getDictionaryBySystemName("millimeters").getId();
            UNIT_POUNDS = proxy.getDictionaryBySystemName("pounds_local").getId();
            UNIT_YEARS = proxy.getDictionaryBySystemName("years_local").getId();
            GEST_AGE_LMP = proxy.getDictionaryBySystemName("gest_age_date_type_lmp").getId();
            GEST_AGE_US = proxy.getDictionaryBySystemName("gest_age_date_type_us").getId();
            INT_POSITIVE = proxy.getDictionaryBySystemName("positive").getId();
            INT_NEGATIVE = proxy.getDictionaryBySystemName("negative").getId();
            ACTION_US = proxy.getDictionaryBySystemName("ms_rec_action_us").getId();
            ACTION_US_AMN = proxy.getDictionaryBySystemName("ms_rec_action_us_amn").getId();
            ACTION_NO_ACTION = proxy.getDictionaryBySystemName("ms_rec_action_no_action").getId();
            YES_STR = YES.toString();

            /*
             * the formatter that converts from string to date
             */
            dateFormatter = new DateTimeFormat(Messages.get().datePattern(), new DefaultDateTimeFormatInfo()) {
            };
        }
        proxy.log(Level.FINE, "Initialized MSNTDScriptlet1", null);
    } catch (Exception e) {
        initialized = false;
        proxy.log(Level.SEVERE, "Failed to initialize dictionary constants", e);
    }
}

From source file:org.openelis.scriptlet.ms.quad.Scriptlet.java

License:Open Source License

public Scriptlet(ScriptletProxy proxy, Integer analysisId) {
    this.proxy = proxy;
    this.analysisId = analysisId;

    proxy.log(Level.FINE, "Initializing MSQuadScriptlet1", null);
    try {/*www .  j  av  a2s . c  om*/
        if (!initialized) {
            initialized = true;
            YES = proxy.getDictionaryBySystemName("yes").getId();
            NO = proxy.getDictionaryBySystemName("no").getId();
            UNIT_MM = proxy.getDictionaryBySystemName("millimeters").getId();
            UNIT_POUNDS = proxy.getDictionaryBySystemName("pounds_local").getId();
            UNIT_YEARS = proxy.getDictionaryBySystemName("years_local").getId();
            GEST_AGE_LMP = proxy.getDictionaryBySystemName("gest_age_date_type_lmp").getId();
            GEST_AGE_US = proxy.getDictionaryBySystemName("gest_age_date_type_us").getId();
            INT_POSITIVE = proxy.getDictionaryBySystemName("positive").getId();
            INT_NEGATIVE = proxy.getDictionaryBySystemName("negative").getId();
            INT_UNKNOWN = proxy.getDictionaryBySystemName("unknown").getId();
            ACTION_US = proxy.getDictionaryBySystemName("ms_rec_action_us").getId();
            ACTION_AMN = proxy.getDictionaryBySystemName("ms_rec_action_amn").getId();
            ACTION_US_AMN = proxy.getDictionaryBySystemName("ms_rec_action_us_amn").getId();
            ACTION_NO_ACTION = proxy.getDictionaryBySystemName("ms_rec_action_no_action").getId();
            ACTION_RISK_NOT_CALC = proxy.getDictionaryBySystemName("ms_rec_action_risk_not_calc").getId();
            YES_STR = YES.toString();

            /*
             * the formatter that converts from string to date
             */
            dateFormatter = new DateTimeFormat(Messages.get().datePattern(), new DefaultDateTimeFormatInfo()) {
            };
        }
        proxy.log(Level.FINE, "Initialized MSQuadScriptlet1", null);
    } catch (Exception e) {
        initialized = false;
        proxy.log(Level.SEVERE, "Failed to initialize dictionary constants", e);
    }
}