/** Returns the default locale, either {@link #getLocale} or * {@link Locales#getCurrent} (never null). * It is useful when you wan to get a locale for this input. * @since 5.0.10 */ protected Locale getDefaultLocale() { return _locale != null ? _locale : Locales.getCurrent(); }
private static final Locale getLocale() { return Locales.getCurrent(); } /** Creates a MessageFormat with the given pattern and uses it to
private static final Locale getLocale() { return Locales.getCurrent(); }
/** Converts all of the characters in this String to upper case using the rules of the current Locale. * @see Locales#getCurrent * @since 5.0.7 */ public static String toLowerCase(String s) { return s != null ? s.toLowerCase(Locales.getCurrent()): null; } /** Converts all of the characters in this String to upper case using the rules of the current Locale.
/** Converts all of the characters in this String to upper case using the rules of the current Locale. * @see Locales#getCurrent * @since 5.0.7 */ public static String toUpperCase(String s) { return s != null ? s.toUpperCase(Locales.getCurrent()): null; } /** Returns a copy of the string, with leading and trailing whitespace omitted.
private static final DateFormat getDateFormat(boolean dateOnly) { final Locale locale = Locales.getCurrent(); return dateOnly ? DateFormat.getDateInstance(DateFormat.DEFAULT, locale): DateFormat.getDateTimeInstance( DateFormat.DEFAULT, DateFormat.DEFAULT, locale); } }
private static final DecimalFormat getDecimalFormat (String pattern, Locale locale) { final DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(locale != null ? locale : Locales.getCurrent()); if (pattern != null) df.applyPattern(pattern); return df; } private static final DateFormat getDateFormat (String pattern, Locale locale, TimeZone timezone, String dateStyle, String timeStyle) {
private static DecimalFormat getLocalizedDecimalFormat(String pattern) { final DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(Locales.getCurrent()); df.applyPattern(pattern); return df; } }
/** Returns whether the current locale ({@link #getCurrent}) belongs * to the specified language and/or country. * * @param lang the language code, e.g., en and zh. Ignored if null. * @param country the country code, e.g., US. Ignored if null. * If empty, it means no country code at all. */ public static final boolean testCurrent(String lang, String country) { final Locale l = getCurrent(); return (lang == null || lang.equals(l.getLanguage())) && (country == null || country.equals(l.getCountry())); } /**
/** Returns the date format of the time only, * * <p>Default: it uses SimpleDateFormat to format the date. */ protected DateFormat getDateFormat(String fmt) { final DateFormat df = new SimpleDateFormat(fmt, _locale != null ? _locale : Locales.getCurrent()); final TimeZone tz = _tzone != null ? _tzone : TimeZones.getCurrent(); df.setTimeZone(tz); return df; }
private static SimpleDateFormat getDateFormat(TimeZone tzone) { SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd", Locales.getCurrent()); df.setTimeZone(tzone != null ? tzone : TimeZones.getCurrent()); return df; }
/** Returns the label of the specified key for the current locale, * or null if not found. * @see #getSegmentedLabels */ public String getLabel(String key) { return getLabel(Locales.getCurrent(), key); } /** Returns the label of the specified key for the specified locale,
private DateFormat getDateFormat() { final DateFormat df = new SimpleDateFormat("yyyy/MM/dd", Locales.getCurrent()); df.setTimeZone(TimeZones.getCurrent()); return df; }
private static SimpleDateFormat getLocalizedSimpleDateFormat(String formatPtn) { SimpleDateFormat sdf = new SimpleDateFormat(formatPtn, Locales.getCurrent()); sdf.setTimeZone(TimeZones.getCurrent()); return sdf; } }
private static SimpleDateFormat getLocalizedSimpleDateFormat(String formatPtn) { SimpleDateFormat sdf = new SimpleDateFormat(formatPtn, Locales.getCurrent()); sdf.setTimeZone(TimeZones.getCurrent()); return sdf; } }
private static final DateFormat getDateFormat (String pattern, Locale locale, TimeZone timezone, String dateStyle, String timeStyle) { if (locale == null) locale = Locales.getCurrent(); if (timezone == null) timezone = TimeZones.getCurrent(); pattern = getRealFormat(pattern, locale, dateStyle, timeStyle); final DateFormat df = new SimpleDateFormat(pattern, locale); df.setTimeZone(timezone); return df; } private static final String getRealFormat (String pattern, Locale locale, String dateStyle, String timeStyle) {
/** * Return a string representation of this BigDecimal without an exponent * field, which respects the given locale. * @param locale if null, the current user locale is used. * @since 5.0.10 */ public static final String toLocaleString(BigDecimal bd, Locale locale) { if (locale == null) locale = Locales.getCurrent(); final DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale); final char DECIMAL = symbols.getDecimalSeparator(); final char MINUS = symbols.getMinusSign(); // only replace MINUS and DECIMAL as toPlainString() implementation // only involves these two chars. return toPlainString(bd).replace('.', DECIMAL).replace('-', MINUS); }
/** * Returns the localized format, which is used when constructing a datebox. * <p> * You might override this method to provide your own localized format. */ protected String getLocalizedFormat() { return new SimpleDateFormat(getRealFormat(), _locale != null ? _locale : Locales.getCurrent()) .toLocalizedPattern(); }
/** Generates Locale-dependent strings in JavaScript syntax. */ public static final String outLocaleJavaScript() { final Locale locale = Locales.getCurrent(); return outNumberJavaScript(locale) + outDateJavaScript(locale); }
public ExecutionCarryOver(Desktop desktop) { _exec = Executions.getCurrent(); if (_exec == null || _exec.getDesktop() != desktop) throw new IllegalStateException("Wrong execution: " + _exec); _locale = Locales.getCurrent(); _timeZone = TimeZones.getCurrent(); }