java.util.Locale#getDefault ( )源码实例Demo

下面列出了java.util.Locale#getDefault ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: cuba   文件: InMemoryConstraintTest.java
@Test
public void testConstraintByAttributeNotInView() throws LoginException {
    AuthenticationManager lw = AppBeans.get(AuthenticationManager.NAME);
    Credentials credentials = new LoginPasswordCredentials("constraintUser4", PASSWORD, Locale.getDefault());
    UserSession userSession = lw.login(credentials).getSession();
    assertNotNull(userSession);

    UserSessionSource uss = AppBeans.get(UserSessionSource.class);
    UserSession savedUserSession = uss.getUserSession();
    ((TestUserSessionSource) uss).setUserSession(userSession);
    try {
        DataManager dataManager = AppBeans.get(DataManager.NAME);
        dataManager = dataManager.secure();
        LoadContext loadContext = new LoadContext(User.class).setView(View.MINIMAL);
        loadContext.setQuery(new LoadContext.Query("select u from sec$User u where u.login = 'constraintUser4' order by u.login desc"));
        loadContext.getQuery().setMaxResults(30);
        loadContext.getQuery().setFirstResult(0);
        List<User> resultList = dataManager.loadList(loadContext);
        assertEquals(1, resultList.size());
        assertEquals("constraintUser4",resultList.get(0).getLogin());

    } finally {
        ((TestUserSessionSource) uss).setUserSession(savedUserSession);
    }
}
 
源代码2 项目: onpc   文件: MainPagerAdapter.java
@Override
public CharSequence getPageTitle(int position)
{
    Locale l = Locale.getDefault();
    switch (position)
    {
    case 0:
        return context.getString(R.string.title_monitor).toUpperCase(l);
    case 1:
        return context.getString(R.string.title_media).toUpperCase(l);
    case 2:
        return context.getString(R.string.title_device).toUpperCase(l);
    case 3:
        return context.getString(R.string.title_remote_control).toUpperCase(l);
    case 4:
        return context.getString(R.string.title_remote_interface).toUpperCase(l);
    }
    return null;
}
 
源代码3 项目: cuba   文件: InMemoryConstraintTest.java
@Test
public void testLoadingLastPage() throws LoginException {
    AuthenticationManager lw = AppBeans.get(AuthenticationManager.NAME);
    Credentials credentials = new LoginPasswordCredentials("constraintUser3", PASSWORD, Locale.getDefault());
    UserSession userSession = lw.login(credentials).getSession();
    assertNotNull(userSession);

    UserSessionSource uss = AppBeans.get(UserSessionSource.class);
    UserSession savedUserSession = uss.getUserSession();
    ((TestUserSessionSource) uss).setUserSession(userSession);
    try {
        DataManager dataManager = AppBeans.get(DataManager.NAME);
        dataManager = dataManager.secure();
        LoadContext loadContext = new LoadContext(User.class).setView(View.LOCAL);
        loadContext.setQuery(new LoadContext.Query("select u from sec$User u where (u.login like 'user%' or u.login like 'constraintUser%') order by u.login desc"));
        loadContext.getQuery().setMaxResults(30);
        loadContext.getQuery().setFirstResult(30);
        List<User> resultList = dataManager.loadList(loadContext);
        assertEquals(8, resultList.size());
        assertEquals("user133",resultList.get(0).getLogin());
        assertEquals("user132",resultList.get(1).getLogin());
        assertEquals("user131",resultList.get(2).getLogin());
    } finally {
        ((TestUserSessionSource) uss).setUserSession(savedUserSession);
    }
}
 
private void setDateAndTime() {
    Date date = new Date(transaction.getTime() * 1000);
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.getDefault());
    SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
    etDate.setText(dateFormat.format(date));
    etTime.setText(timeFormat.format(date));
}
 
源代码5 项目: astor   文件: TestDateTime_Properties.java
protected void setUp() throws Exception {
    DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
    zone = DateTimeZone.getDefault();
    locale = Locale.getDefault();
    DateTimeZone.setDefault(LONDON);
    Locale.setDefault(Locale.UK);
}
 
源代码6 项目: coming   文件: elixir1_one_s.java
/**
 * <p>Gets a date formatter instance using the specified style, time
 * zone and locale.</p>
 * 
 * @param style  date style: FULL, LONG, MEDIUM, or SHORT
 * @param timeZone  optional time zone, overrides time zone of
 *  formatted date
 * @param locale  optional locale, overrides system locale
 * @return a localized standard date formatter
 * @throws IllegalArgumentException if the Locale has no date
 *  pattern defined
 */
public static synchronized FastDateFormat getDateInstance(int style, TimeZone timeZone, Locale locale) {
    Object key = Integer.valueOf(style);
    if (timeZone != null) {
        key = new Pair(key, timeZone);
    }

    if (locale == null) {
        locale = Locale.getDefault();
    }

    key = new Pair(key, locale);

    FastDateFormat format = cDateInstanceCache.get(key);
    if (format == null) {
        try {
            SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateInstance(style, locale);
            String pattern = formatter.toPattern();
            format = getInstance(pattern, timeZone, locale);
            cDateInstanceCache.put(key, format);
            
        } catch (ClassCastException ex) {
            throw new IllegalArgumentException("No date pattern for locale: " + locale);
        }
    }
    return format;
}
 
源代码7 项目: Milkomeda   文件: I18nLocaleResolver.java
@Override
public Locale resolveLocale(HttpServletRequest request) {
    // 是否有固定的设置
    Locale defaultLocale = getDefaultLocale();
    if (defaultLocale != null) {
        return defaultLocale;
    }

    // 设置本地语言
    return Locale.getDefault();
}
 
源代码8 项目: coming   文件: Arja_0071_t.java
/**
 * <p>Gets a date/time formatter instance using the specified style,
 * time zone and locale.</p>
 * 
 * @param dateStyle  date style: FULL, LONG, MEDIUM, or SHORT
 * @param timeStyle  time style: FULL, LONG, MEDIUM, or SHORT
 * @param timeZone  optional time zone, overrides time zone of
 *  formatted date
 * @param locale  optional locale, overrides system locale
 * @return a localized standard date/time formatter
 * @throws IllegalArgumentException if the Locale has no date/time
 *  pattern defined
 */
public static synchronized FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle, TimeZone timeZone,
        Locale locale) {

    Object key = new Pair(new Integer(dateStyle), new Integer(timeStyle));
    if (timeZone != null) {
        key = new Pair(key, timeZone);
    }
    if (locale != null) {
        key = new Pair(key, locale);
    }

    FastDateFormat format = (FastDateFormat) cDateTimeInstanceCache.get(key);
    if (format == null) {
        if (locale == null) {
            locale = Locale.getDefault();
        }
        try {
            SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateTimeInstance(dateStyle, timeStyle,
                    locale);
            String pattern = formatter.toPattern();
            format = getInstance(pattern, timeZone, locale);
            if (pattern == null) {
            	  throw new IllegalArgumentException("The pattern must not be null");
            	}

        } catch (ClassCastException ex) {
            throw new IllegalArgumentException("No date time pattern for locale: " + locale);
        }
    }
    return format;
}
 
源代码9 项目: dss   文件: I18nProviderTest.java
@Test
public void nestedMessageTagTest() {
	Locale systemLocale = Locale.getDefault();
	try {
		Locale.setDefault(Locale.ENGLISH);
		
		MessageTag validationTime = MessageTag.VT_VALIDATION_TIME;
		MessageTag messageTag = MessageTag.CERT_QUALIFICATION_AT_TIME.setArgs(validationTime);
	
		final I18nProvider i18nProvider = new I18nProvider(Locale.ENGLISH);
		String message = i18nProvider.getMessage(messageTag);
		assertNotNull(message);
		assertEquals("Certificate Qualification at validation time", message);
		
		final I18nProvider i18nFrenchProvider = new I18nProvider(Locale.FRENCH);
		message = i18nFrenchProvider.getMessage(messageTag);
		assertNotNull(message);
		assertEquals("Qualification du certificat au moment de la validation", message);

		final I18nProvider i18nGermanProvider = new I18nProvider(Locale.GERMAN);
		message = i18nGermanProvider.getMessage(messageTag);
		assertNotNull(message);
		assertEquals("Certificate Qualification at validation time", message);
	} finally {
		Locale.setDefault(systemLocale); // restore default
	}
}
 
源代码10 项目: bcm-android   文件: SystemUtils.java
public static String getSystemInfo() {
    Date date = new Date(System.currentTimeMillis());
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
    String time = dateFormat.format(date);
    StringBuilder sb = new StringBuilder();
    sb.append("_______  systemInfo  ").append(time).append(" ______________");
    sb.append("\nID                 :").append(Build.ID);
    sb.append("\nBRAND              :").append(Build.BRAND);
    sb.append("\nMODEL              :").append(Build.MODEL);
    sb.append("\nRELEASE            :").append(Build.VERSION.RELEASE);
    sb.append("\nSDK                :").append(Build.VERSION.SDK);

    sb.append("\n_______ OTHER _______");
    sb.append("\nBOARD              :").append(Build.BOARD);
    sb.append("\nPRODUCT            :").append(Build.PRODUCT);
    sb.append("\nDEVICE             :").append(Build.DEVICE);
    sb.append("\nFINGERPRINT        :").append(Build.FINGERPRINT);
    sb.append("\nHOST               :").append(Build.HOST);
    sb.append("\nTAGS               :").append(Build.TAGS);
    sb.append("\nTYPE               :").append(Build.TYPE);
    sb.append("\nTIME               :").append(Build.TIME);
    sb.append("\nINCREMENTAL        :").append(Build.VERSION.INCREMENTAL);

    sb.append("\n_______ CUPCAKE-3 _______");
    sb.append("\nDISPLAY            :").append(Build.DISPLAY);

    sb.append("\n_______ DONUT-4 _______");
    sb.append("\nSDK_INT            :").append(Build.VERSION.SDK_INT);
    sb.append("\nMANUFACTURER       :").append(Build.MANUFACTURER);
    sb.append("\nBOOTLOADER         :").append(Build.BOOTLOADER);
    sb.append("\nCPU_ABI            :").append(Build.CPU_ABI);
    sb.append("\nCPU_ABI2           :").append(Build.CPU_ABI2);
    sb.append("\nHARDWARE           :").append(Build.HARDWARE);
    sb.append("\nUNKNOWN            :").append(Build.UNKNOWN);
    sb.append("\nCODENAME           :").append(Build.VERSION.CODENAME);

    sb.append("\n_______ GINGERBREAD-9 _______");
    sb.append("\nSERIAL             :").append(Build.SERIAL);
    return sb.toString();
}
 
源代码11 项目: WiFiAnalyzer   文件: VendorUtils.java
@NonNull
static String clean(String macAddress) {
    if (macAddress == null) {
        return StringUtils.EMPTY;
    }
    String result = macAddress.replace(SEPARATOR, "");
    Locale locale = Locale.getDefault();
    return result.substring(0, Math.min(result.length(), MAX_SIZE)).toUpperCase(locale);
}
 
源代码12 项目: j2objc   文件: TimeZoneTest.java
/**
 * @add test {@link java.util.TimeZone#getDisplayName(boolean, int)}
 */
public void test_getDisplayName_ZI() {
    TimeZone defaultZone = TimeZone.getDefault();
    Locale defaultLocale = Locale.getDefault();
    String actualName = defaultZone.getDisplayName(false, TimeZone.LONG);
    String expectedName = defaultZone.getDisplayName(false, TimeZone.LONG,
            defaultLocale);
    assertEquals(
            "getDisplayName(daylight,style) did not return the default locale suitable name",
            expectedName, actualName);
}
 
源代码13 项目: projectforge-webapp   文件: StringComparator.java
private Collator getDefaultCollator()
{
  if (defaultCollator == null) {
    Locale locale = ConfigXml.getInstance().getDefaultLocale();
    if (locale == null) {
      locale = Locale.getDefault();
    }
    defaultCollator = Collator.getInstance(locale);
  }
  return defaultCollator;
}
 
源代码14 项目: coming   文件: Time_9_DateTimeZone_t.java
/**
 * Gets the short name of this datetime zone suitable for display using
 * the specified locale.
 * <p>
 * If the name is not available for the locale, then this method returns a
 * string in the format <code>[+-]hh:mm</code>.
 * 
 * @param instant  milliseconds from 1970-01-01T00:00:00Z to get the name for
 * @param locale  the locale to get the name for
 * @return the human-readable short name in the specified locale
 */
public String getShortName(long instant, Locale locale) {
    if (locale == null) {
        locale = Locale.getDefault();
    }
    String nameKey = getNameKey(instant);
    if (nameKey == null) {
        return iID;
    }
    String name = cNameProvider.getShortName(locale, iID, nameKey);
    if (name != null) {
        return name;
    }
    return printOffset(getOffset(instant));
}
 
源代码15 项目: pentaho-reporting   文件: DefaultLocaleSettings.java
public Locale getLocale() {
  return Locale.getDefault();
}
 
源代码16 项目: pentaho-reporting   文件: SettingsMessages.java
/**
 * Creates a new instance.
 */
private SettingsMessages() {
  super( Locale.getDefault(), "org.pentaho.reporting.designer.core.settings.messages.messages",//NON-NLS
    ObjectUtilities.getClassLoader( SettingsMessages.class ) );
}
 
源代码17 项目: microba   文件: CalendarPane.java
/**
 * Constructor.
 */
public CalendarPane() {
	this(null, 0, Locale.getDefault(), TimeZone.getDefault());
}
 
源代码18 项目: astor   文件: TestPeriodFormat.java
protected void setUp() throws Exception {
    originalLocale = Locale.getDefault();
    Locale.setDefault(DE);
}
 
源代码19 项目: twitter-kit-android   文件: BasicTimelineFilter.java
public BasicTimelineFilter(FilterValues filterValues) {
    this(filterValues, Locale.getDefault());
}
 
源代码20 项目: effective_android_sample   文件: TextRecord.java
public TextRecord(String text) {
	this(text, UTF8, Locale.getDefault());
}