public static String format(Date date, String pattern, String lang) { return new SimpleDateFormat(pattern, Lang.getLocaleOrDefault(lang)).format(date); }
public static String format(Date date, String pattern, String lang, String timezone) { DateFormat df = new SimpleDateFormat(pattern, Lang.getLocaleOrDefault(lang)); df.setTimeZone(TimeZone.getTimeZone(timezone)); return df.format(date); }
public static String asdate(Long timestamp, String pattern, String lang) { return new SimpleDateFormat(pattern, Lang.getLocaleOrDefault(lang)).format(new Date(timestamp)); }
/** * @return the default locale if the Locale cannot be found otherwise the locale * associated to the current Lang. */ public static Locale getLocale() { return getLocaleOrDefault(get()); }
public static String getMessage(String locale, Object key, Object... args) { // Check if there is a plugin that handles translation String message = Play.pluginCollection.getMessage(locale, key, args); if (message != null) { return message; } if (key == null) { return ""; } String value = null; if (locales != null) { if (locales.containsKey(locale)) { value = locales.get(locale).getProperty(key.toString()); } if (value == null && locale != null && locale.length() == 5 && locales.containsKey(locale.substring(0, 2))) { value = locales.get(locale.substring(0, 2)).getProperty(key.toString()); } } if (value == null && defaults != null) { value = defaults.getProperty(key.toString()); } if (value == null) { value = key.toString(); } Locale l = Lang.getLocaleOrDefault(locale); return formatString(l, value, args); }