List of usage examples for java.util Locale Locale
public Locale(String language)
From source file:Main.java
public static String getDateByNumber() { SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd", new Locale("zh")); String cur = s.format(new Date()); return cur;//from w w w . ja v a 2s .c o m }
From source file:Main.java
public static void setLocale(final Context ctx, final String lang) { final Locale loc = new Locale(lang); Locale.setDefault(loc);/*from www . ja v a 2 s. c om*/ final Configuration cfg = new Configuration(); cfg.locale = loc; ctx.getResources().updateConfiguration(cfg, null); }
From source file:Main.java
public static void setLanguge(Context ctx, String languageToLoad) { Locale locale = new Locale(languageToLoad); Locale.setDefault(locale);/*from ww w .j a va2s. com*/ Configuration config = new Configuration(); config.locale = locale; ctx.getResources().updateConfiguration(config, ctx.getResources().getDisplayMetrics()); }
From source file:Main.java
private static void updateResources(Context context, String language) { Locale locale = new Locale(language); Locale.setDefault(locale);// w w w.jav a2 s .c om Resources resources = context.getResources(); Configuration configuration = new Configuration(resources.getConfiguration()); configuration.locale = locale; resources.updateConfiguration(configuration, resources.getDisplayMetrics()); }
From source file:Main.java
public static String getImageName() { Date date = new Date(); SimpleDateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd", new Locale("en")); dFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return "Wallpaper-" + dFormat.format(date) + ".jpg"; }
From source file:Main.java
public static String getTodayDate() { TimeZone currZone = TimeZone.getTimeZone("Asia/Singapore"); Calendar myCal = Calendar.getInstance(currZone, new Locale("en")); SimpleDateFormat sdf = new SimpleDateFormat(); sdf.applyPattern("yyyy-MM-dd"); return (sdf.format(myCal.getTime())); }
From source file:Main.java
public static void updateResources(Context context, String language) { //set the language of the app Locale locale = new Locale(language); Locale.setDefault(locale);/*from w w w. j a v a2 s. c o m*/ Resources resources = context.getResources(); Configuration configuration = resources.getConfiguration(); configuration.locale = locale; resources.updateConfiguration(configuration, resources.getDisplayMetrics()); }
From source file:Main.java
private static void updateResources(Context context, String language) { Locale locale = new Locale(language); Locale.setDefault(locale);// ww w.j a va 2s .c o m Resources resources = context.getResources(); Configuration configuration = resources.getConfiguration(); configuration.locale = locale; resources.updateConfiguration(configuration, resources.getDisplayMetrics()); }
From source file:Main.java
/** * Update language//from ww w. ja v a 2s . c o m * * @param code The language code. Like: en, cz, iw, ... */ public static void updateLanguage(Context context, String code) { Locale locale = new Locale(code); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics()); }
From source file:Main.java
public static Locale createLocaleFromString(String localeStr) { if (null == localeStr) return Locale.getDefault(); String[] brokenDownLocale = localeStr.split("_", 3); if (1 == brokenDownLocale.length) { return new Locale(brokenDownLocale[0]); } else if (2 == brokenDownLocale.length) { return new Locale(brokenDownLocale[0], brokenDownLocale[1]); } else {/*from www .ja v a 2 s . c om*/ return new Locale(brokenDownLocale[0], brokenDownLocale[1], brokenDownLocale[2]); } }