List of usage examples for java.util Locale getDefault
public static Locale getDefault()
From source file:Main.java
/** * Return the string value associated with a particular resource ID, * substituting the format arguments as defined in {@link java.util.Formatter} * and {@link java.lang.String#format}. It will be stripped of any styled text * information.//from ww w .j av a 2s. c om * * @param id The desired resource identifier, as generated by the aapt * tool. This integer encodes the package, type, and resource * entry. The value 0 is an invalid identifier. * @param formatArgs The format arguments that will be used for substitution. * @return String The string data associated with the resource, * stripped of styled text information. * @throws Resources.NotFoundException Throws NotFoundException if the given ID does not exist. */ @NonNull public static String getString(@NonNull Resources resources, @StringRes int id, Object... formatArgs) { try { return resources.getString(id, formatArgs); } catch (IllegalFormatException e) { final String message = "Failed to format the string resource! The user locale is:" + Locale.getDefault().toString(); throw new IllegalArgumentException(message, e); } }
From source file:IteratorTest.java
public IteratorTest() { localeButton.setRenderer(new LocaleListCellRenderer()); localeButton.setSelectedItem(Locale.getDefault()); add(localeButton);/*from w w w . ja va 2 s . c om*/ textArea.setLineWrap(true); textArea.setWrapStyleWord(true); add(new JScrollPane(textArea)); add(getTypePanel()); add(getCountPanel()); add(new JScrollPane(itemList)); refreshDisplay(); }
From source file:GmtCalendar.java
/** * Constructs a GmtCalendar with the given date set in the GMT time zone * with the default locale./* w w w . j a v a 2 s . c om*/ * * @param year * the value used to set the YEAR time field in the calendar. * @param month * the value used to set the MONTH time field in the calendar. * Month value is 0-based. e.g., 0 for January. * @param date * the value used to set the DATE time field in the calendar. */ public GmtCalendar(int year, int month, int date) { super(TimeZone.getTimeZone("GMT"), Locale.getDefault()); this.set(ERA, AD); this.set(YEAR, year); this.set(MONTH, month); this.set(DATE, date); }
From source file:com.relicum.ipsum.Locale.LocaleManager.java
public LocaleManager(Plugin p) { Validate.notNull(p);//from w w w.j av a 2 s .com String[] l = p.getConfig().getString("locale", "en_GB").split("_"); setLocale(l[0], l[1]); if (p.getConfig().getBoolean("messages.saveFiles") && !p.getConfig().getBoolean("messages.devMode")) { saveToDisk(p); p.getConfig().set("messages.saveFiles", false); } p.getLogger().info("Language locale has been set to " + Locale.getDefault().toLanguageTag()); }
From source file:com.liferay.tasks.ui.model.TaskModel.java
public String getModifiedDate() { SimpleDateFormat formatter = new SimpleDateFormat("MMM d, HH:mm", Locale.getDefault()); return formatter.format(new Date(_modifiedDate)); }
From source file:com.libframework.annotation.util.OtherUtils.java
/** * @param context if null, use the default format * (Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 %sSafari/534.30). * @return//from w w w .j a v a2 s .com */ public static String getUserAgent(Context context) { String webUserAgent = null; if (context != null) { try { Class<?> sysResCls = Class.forName("com.android.internal.R$string"); Field webUserAgentField = sysResCls.getDeclaredField("web_user_agent"); Integer resId = (Integer) webUserAgentField.get(null); webUserAgent = context.getString(resId); } catch (Throwable ignored) { } } if (TextUtils.isEmpty(webUserAgent)) { webUserAgent = "Mozilla/5.0 (Linux; U; Android %s) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 %sSafari/533.1"; } Locale locale = Locale.getDefault(); StringBuffer buffer = new StringBuffer(); // Add version final String version = Build.VERSION.RELEASE; if (version.length() > 0) { buffer.append(version); } else { // default to "1.0" buffer.append("1.0"); } buffer.append("; "); final String language = locale.getLanguage(); if (language != null) { buffer.append(language.toLowerCase(Locale.getDefault())); final String country = locale.getCountry(); if (country != null) { buffer.append("-"); buffer.append(country.toLowerCase(Locale.getDefault())); } } else { // default to "en" buffer.append("en"); } // add the model for the release build if ("REL".equals(Build.VERSION.CODENAME)) { final String model = Build.MODEL; if (model.length() > 0) { buffer.append("; "); buffer.append(model); } } final String id = Build.ID; if (id.length() > 0) { buffer.append(" Build/"); buffer.append(id); } return String.format(webUserAgent, buffer, "Mobile "); }
From source file:com.orchestra.portale.external.services.manager.BikeSharingService.java
@Override public String getResponse(Map<String, String[]> mapParams) { try {// w ww. j a v a 2s .com HttpURLConnection urlConnection = (HttpURLConnection) new URL(baseUrl).openConnection(); urlConnection.setConnectTimeout(15000); urlConnection.setReadTimeout(30000); urlConnection.addRequestProperty("Accept-Language", Locale.getDefault().toString().replace('_', '-')); String result = IOUtils.toString(urlConnection.getInputStream()); urlConnection.disconnect(); return result; } catch (IOException e) { return "response{code:1,error:" + e.getMessage() + "}"; } }
From source file:gov.nih.nci.cabig.caaers.web.ae.AeTabTestCase.java
@Override protected void setUp() throws Exception { super.setUp(); messageSource = new StaticMessageSource(); messageSource.addMessage("instruction_ae_modification_detected", Locale.getDefault(), "Testing"); tab = createTab();// w ww.j ava 2s.c om tab.setMessageSource(messageSource); tab.setExpeditedReportTree(expeditedReportTree); tab.setEvaluationService(evaluationService); }
From source file:org.croodie.resource.RootServerResource.java
@Get("json") public String represent() { Date date = new Date(); DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.getDefault()); String formattedDate = dateFormat.format(date); return formattedDate; }
From source file:com.coffeebeans.services.service.version.VersionServiceImpl.java
@Override public ApiVersion getVersion() { ApiVersion version = new ApiVersion(); String buildVersion = messageSource.getMessage("build.version", null, Locale.getDefault()); version.setBuildVersion(buildVersion); String buildTime = messageSource.getMessage("build.time", null, Locale.getDefault()); version.setTimestamp(buildTime);//from ww w . j a v a 2s .co m String apiVersion = messageSource.getMessage("api.version", null, Locale.getDefault()); version.setApiVersion(apiVersion); LOGGER.debug("API version is [{}]", version); return version; }