Examples of AuraLocale


Examples of org.auraframework.util.AuraLocale

    @Override
    public Date parseTime(String time, Locale locale, TimeZone timeZone, int timeStyle) throws ParseException {
        if (time == null) {
            return null;
        }
        AuraLocale loc = Aura.getLocalizationAdapter().getAuraLocale();
        if (locale == null) {
            locale = loc.getDateLocale();
        }
        if (timeZone == null) {
            timeZone = loc.getTimeZone();
        }
        return dateService.getTimeStyleConverter(locale, timeStyle).parse(time, timeZone);
    }
View Full Code Here

Examples of org.auraframework.util.AuraLocale

    public Calendar parseTimeToCalendar(String time, Locale locale, TimeZone timeZone, int timeStyle)
            throws ParseException {
        if (time == null) {
            return null;
        }
        AuraLocale loc = Aura.getLocalizationAdapter().getAuraLocale();
        if (locale == null) {
            locale = loc.getDateLocale();
        }
        if (timeZone == null) {
            timeZone = loc.getTimeZone();
        }
        Calendar c = Calendar.getInstance(timeZone, locale);
        c.setTime(parseTime(time, locale, timeZone, timeStyle));
        return c;
    }
View Full Code Here

Examples of org.auraframework.util.AuraLocale

    public Date parseDateTime(String dateTime, Locale locale, TimeZone timeZone, int dateStyle, int timeStyle)
            throws ParseException {
        if (dateTime == null) {
            return null;
        }
        AuraLocale loc = Aura.getLocalizationAdapter().getAuraLocale();
        if (locale == null) {
            locale = loc.getDateLocale();
        }
        if (timeZone == null) {
            timeZone = loc.getTimeZone();
        }
        return dateService.getDateTimeStyleConverter(locale, dateStyle, timeStyle).parse(dateTime, timeZone);
    }
View Full Code Here

Examples of org.auraframework.util.AuraLocale

    @Override
    public Date parseDateTime(String dateTime, Locale locale, TimeZone timeZone, String format) throws ParseException {
        if (dateTime == null) {
            return null;
        }
        AuraLocale loc = Aura.getLocalizationAdapter().getAuraLocale();
        if (locale == null) {
            locale = loc.getDateLocale();
        }
        if (timeZone == null) {
            timeZone = loc.getTimeZone();
        }
        return dateService.getPatternConverter(locale, format).parse(dateTime, timeZone);
    }
View Full Code Here

Examples of org.auraframework.util.AuraLocale

    public Calendar parseDateTimeToCalendar(String dateTime, Locale locale, TimeZone timeZone, int dateStyle,
            int timeStyle) throws ParseException {
        if (dateTime == null) {
            return null;
        }
        AuraLocale loc = Aura.getLocalizationAdapter().getAuraLocale();
        if (locale == null) {
            locale = loc.getDateLocale();
        }
        if (timeZone == null) {
            timeZone = loc.getTimeZone();
        }
        Calendar c = Calendar.getInstance(timeZone, locale);
        c.setTime(parseDateTime(dateTime, locale, timeZone, dateStyle, timeStyle));
        return c;
    }
View Full Code Here

Examples of org.auraframework.util.AuraLocale

    private final Map<String, Object> data;

    public LocaleValueProvider() {
        Builder<String, Object> builder = ImmutableMap.builder();

        AuraLocale al = Aura.getLocalizationAdapter().getAuraLocale();

        Locale userLocale = al.getLocale();
        Locale lang = al.getLanguageLocale();
        Locale dateLocale = al.getDateLocale();

        builder.put(USER_LOCALE_LANGUAGE, userLocale.getLanguage());
        builder.put(USER_LOCALE_COUNTRY, userLocale.getCountry());
        builder.put(LANGUAGE, lang.getLanguage());
        builder.put(COUNTRY, lang.getCountry());
        builder.put(VARIANT, lang.getVariant());
        builder.put(LANGUAGE_LOCALE, lang.toString());

        try {
            builder.put(MONTH_NAME, this.getNameOfMonths(al));
            builder.put(WEEKDAY_NAME, this.getNameOfWeekdays(al));
            builder.put(TODAY_LABEL, this.getLabelForToday());
        } catch (QuickFixException qfe) {
            // Ignore
        }

        // using java DateFormat because the year pattern "MMM d, y" (although valid) isn't understood by moment.js
        DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.DEFAULT, dateLocale);
        DateFormat datetimeFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, dateLocale);
        DateFormat timeFormat = DateFormat.getTimeInstance(DateFormat.DEFAULT, dateLocale);
        try {
            SimpleDateFormat sdf = (SimpleDateFormat) dateFormat;
            builder.put(DATE_FORMAT, sdf.toPattern());

            SimpleDateFormat sdtf = (SimpleDateFormat) datetimeFormat;
            builder.put(DATETIME_FORMAT, sdtf.toPattern());

            SimpleDateFormat stf = (SimpleDateFormat) timeFormat;
            builder.put(TIME_FORMAT, stf.toPattern());
        } catch (ClassCastException cce) {
            builder.put(DATE_FORMAT, DEFAULT_DATE_FORMAT);
            builder.put(DATETIME_FORMAT, DEFAULT_DATETIME_FORMAT);
            builder.put(TIME_FORMAT, DEFAULT_TIME_FORMAT);
        }

        builder.put(TIME_ZONE, al.getTimeZone().getID());
        builder.put(TIME_ZONE_FILE_NAME, al.getTimeZone().getID().replace("/", "-"));

        builder.put(IS_EASTERN_NAME_STYLE, al.isEasternNameStyle());

        // DecimalFormat is expected
        DecimalFormat df = (DecimalFormat) DecimalFormat.getNumberInstance(al.getNumberLocale());

        builder.put(NUMBER_FORMAT, df.toLocalizedPattern());
        DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
        builder.put(DECIMAL, dfs.getDecimalSeparator());
        builder.put(GROUPING, dfs.getGroupingSeparator());
        builder.put(ZERO_DIGIT, dfs.getZeroDigit());

        df = (DecimalFormat) DecimalFormat.getPercentInstance(al.getNumberLocale());

        builder.put(PERCENT_FORMAT, df.toLocalizedPattern());

        df = (DecimalFormat) DecimalFormat.getCurrencyInstance(al.getCurrencyLocale());

        builder.put(CURRENCY_FORMAT, df.toLocalizedPattern());
        DecimalFormatSymbols cdfs = df.getDecimalFormatSymbols();
        Currency cur = cdfs.getCurrency();
        builder.put(CURRENCY_CODE, cur != null ? cur.getCurrencyCode() : "");
View Full Code Here

Examples of org.auraframework.util.AuraLocale

    }

    @AuraEnabled
    public Object getLocaleData() {
        List<String> localeData = new LinkedList<>();
        AuraLocale ll = Aura.getLocalizationAdapter().getAuraLocale();
        localeData.add("Currency locale:" + ll.getCurrencyLocale().getDisplayName());
        localeData.add("Date locale:" + ll.getDateLocale().getDisplayName());
        localeData.add("Default locale:" + ll.getDefaultLocale().getDisplayName());
        localeData.add("Language locale:" + ll.getLanguageLocale().getDisplayName());
        localeData.add("Number locale:" + ll.getNumberLocale().getDisplayName());
        localeData.add("System locale:" + ll.getSystemLocale().getDisplayName());

        return localeData;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.