List of usage examples for java.util Locale getDefault
public static Locale getDefault()
From source file:org.opendatakit.utilities.LocalizationUtilsTest.java
@Test public void testHackedName() { Locale defaultLocale = Locale.getDefault(); String full_locale = defaultLocale.getLanguage() + "_" + defaultLocale.getCountry(); assertEquals("aname", LocalizationUtils.getLocalizedDisplayName(appName, tableId, full_locale, NameUtil.normalizeDisplayName(NameUtil.constructSimpleDisplayName("aname")))); assertEquals("a name", LocalizationUtils.getLocalizedDisplayName(appName, tableId, full_locale, NameUtil.normalizeDisplayName(NameUtil.constructSimpleDisplayName("a_name")))); assertEquals("_ an am e", LocalizationUtils.getLocalizedDisplayName(appName, tableId, full_locale, NameUtil.normalizeDisplayName(NameUtil.constructSimpleDisplayName("_an_am_e")))); assertEquals("an ame _", LocalizationUtils.getLocalizedDisplayName(appName, tableId, full_locale, NameUtil.normalizeDisplayName(NameUtil.constructSimpleDisplayName("an_ame_")))); }
From source file:com.liferay.sync.engine.util.SyncSystemTestUtil.java
public static void addUser(String name, long syncAccountId) throws Exception { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("-organizationIds", null); parameters.put("-roleIds", null); parameters.put("-userGroupIds", null); parameters.put("autoPassword", false); parameters.put("autoScreenName", false); parameters.put("birthdayDay", 1); parameters.put("birthdayMonth", 1); parameters.put("birthdayYear", 1901); parameters.put("companyId", getCompanyId(syncAccountId)); parameters.put("emailAddress", name.concat("@liferay.com")); parameters.put("facebookId", 0); parameters.put("firstName", name); parameters.put("groupIds", getGuestGroupId(syncAccountId)); parameters.put("jobTitle", ""); parameters.put("lastName", ""); parameters.put("locale", Locale.getDefault()); parameters.put("male", true); parameters.put("middleName", ""); parameters.put("openId", ""); parameters.put("password1", "test"); parameters.put("password2", "test"); parameters.put("prefixId", 0); parameters.put("screenName", name); parameters.put("sendEmail", false); parameters.put("suffixId", 0); executePost("/user/add-user", parameters, syncAccountId); }
From source file:net.jawr.web.resource.bundle.locale.SpringLocaleResolver.java
public String resolveLocaleCode(HttpServletRequest request) { org.springframework.web.servlet.LocaleResolver resolver = RequestContextUtils.getLocaleResolver(request); Locale resolved = resolver.resolveLocale(request); if (resolved != Locale.getDefault()) return resolved.toString(); else//from w w w.j a v a2 s .co m return null; }
From source file:org.terasoluna.gfw.common.message.ResultMessageUtilsTest.java
@Test public void testResolveMessageLocaleNotPassed() { ResultMessage message = mock(ResultMessage.class); MessageSource messageSource = mock(MessageSource.class); when(message.getCode()).thenReturn("MSG001"); when(message.getArgs()).thenReturn(null); when(messageSource.getMessage("MSG001", null, Locale.getDefault())).thenReturn("MESSAGE_TEXT"); String msg = ResultMessageUtils.resolveMessage(message, messageSource); assertThat(msg, is("MESSAGE_TEXT")); }
From source file:com.github.devnied.emvnfccard.utils.TrackUtils.java
/** * Extract track 2 data/*from w w w. j a va2 s .co m*/ * * @param pEmvCard * Object card representation * @param pData * data to parse * @return true if the extraction succeed false otherwise */ public static boolean extractTrack2Data(final EmvCard pEmvCard, final byte[] pData) { boolean ret = false; byte[] track2 = TlvUtil.getValue(pData, EmvTags.TRACK_2_EQV_DATA, EmvTags.TRACK2_DATA); if (track2 != null) { String data = BytesUtils.bytesToStringNoSpace(track2); Matcher m = TRACK2_PATTERN.matcher(data); // Check pattern if (m.find()) { // read card number pEmvCard.setCardNumber(m.group(1)); // Read expire date SimpleDateFormat sdf = new SimpleDateFormat("yyMM", Locale.getDefault()); try { pEmvCard.setExpireDate(DateUtils.truncate(sdf.parse(m.group(2)), Calendar.MONTH)); } catch (ParseException e) { LOGGER.error("Unparsable expire card date : {}", e.getMessage()); return ret; } // Read service pEmvCard.setService(new Service(m.group(3))); ret = true; } } return ret; }
From source file:org.jasig.springframework.context.ACATester.java
public void setApplicationContext(ApplicationContext ctx) throws ApplicationContextException { // check reinitialization if (this.ac != null) { throw new IllegalStateException("Already initialized"); }/*from w w w . j av a2s . com*/ // check message source availability if (ctx != null) { try { ctx.getMessage("code1", null, Locale.getDefault()); } catch (NoSuchMessageException ex) { // expected } } this.ac = ctx; }
From source file:cn.newcapec.framework.core.utils.dataUtils.DateMorpherEx.java
public DateMorpherEx(String[] formats, boolean lenient) { this(formats, Locale.getDefault(), lenient); }
From source file:com.swisscom.safeconnect.model.PlumberStatsResponse.java
@Override public String toString() { return String.format(Locale.getDefault(), "PlumberStatsResponse {" + "\nphone: %s" + "\nusername: %s" + "\ncurrent: %s" + "\ntoday: %s" + "\nmonth: %s" + "\ntotal: %s" + "\n}", phone, username, currentStats.toString(), todayStats.toString(), monthStats.toString(), totalStats.toString());//from ww w . ja va 2 s .co m }
From source file:com.github.pjungermann.config.validation.ConfigValidationExceptionTest.java
@Test public void getMessage_errors_exceptionWithListOfConfigErrorMessages() { StaticMessageSource messageSource = new StaticMessageSource(); messageSource.addMessage("fake.config.error.A", Locale.getDefault(), "Error A happened: {0}"); messageSource.addMessage("fake.config.error.B", Locale.getDefault(), "Error B happened"); ArrayList<ConfigError> errors = new ArrayList<>(); errors.add(new FakeConfigErrorA(123)); errors.add(new FakeConfigErrorA("2nd")); errors.add(new FakeConfigErrorB()); ConfigValidationException exception = new ConfigValidationException(messageSource, errors); assertEquals("Validation errors:\n" + "- Error A happened: 123\n" + "- Error A happened: 2nd\n" + "- Error B happened", exception.getMessage()); }
From source file:com.example.kyle.weatherforecast.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager) findViewById(R.id.pager); FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager()); viewPager.setAdapter(adapter);//from w ww . ja v a 2 s. c om Calendar calendar = Calendar.getInstance(); String weekDay; SimpleDateFormat dayFormat; dayFormat = new SimpleDateFormat("cccc", Locale.getDefault()); // dayFormat = new SimpleDateFormat("c LLL d", Locale.getDefault()); // dayFormat = (SimpleDateFormat) new SimpleDateFormat().getDateInstance(); actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.addTab(actionBar.newTab().setText("Today").setTabListener(this)); for (int i = 1; i < 5; i++) { calendar.add(Calendar.DAY_OF_WEEK, 1); weekDay = dayFormat.format(calendar.getTime()); actionBar.addTab(actionBar.newTab().setText(weekDay).setTabListener(this)); } if (notificationId == 0) { postAlert(0); } viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int i, float v, int i2) { } @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } @Override public void onPageScrollStateChanged(int i) { } }); }