當前位置: 首頁>>代碼示例>>Java>>正文


Java Locale類代碼示例

本文整理匯總了Java中java.util.Locale的典型用法代碼示例。如果您正苦於以下問題:Java Locale類的具體用法?Java Locale怎麽用?Java Locale使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Locale類屬於java.util包,在下文中一共展示了Locale類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createDetailsSection

import java.util.Locale; //導入依賴的package包/類
private JComponent createDetailsSection()
{
	final JLabel titleLabel = new JLabel(CurrentLocale.get("wizard.controls.title")); //$NON-NLS-1$
	final JLabel descriptionLabel = new JLabel(CurrentLocale.get("wizard.controls.description")); //$NON-NLS-1$

	final Set<Locale> langs = BundleCache.getLanguages();
	title = new I18nTextField(langs);
	description = new I18nTextField(langs);
	mandatory = new JCheckBox(CurrentLocale.get("wizard.controls.mandatory")); //$NON-NLS-1$
	selectMultiple = new JCheckBox(getString("usersel.selectmultiple")); //$NON-NLS-1$

	final JPanel all = new JPanel(new MigLayout("wrap", "[][grow, fill]"));

	all.add(titleLabel);
	all.add(title);
	all.add(descriptionLabel);
	all.add(description);
	all.add(mandatory, "span 2");
	all.add(selectMultiple, "span 2");

	return all;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:23,代碼來源:UserSelectorControlEditor.java

示例2: date2flydate

import java.util.Locale; //導入依賴的package包/類
public static String date2flydate(String date) {
    SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
    Date d = null;
    long l = 0;
    try {
        d = dft.parse(date);
        l = d.getTime();
    } catch (ParseException e) {
        e.printStackTrace();
    }

    Date new_date = new Date(l + 1000 * 60 * 15);
    SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
    String time = f.format(new_date);
    return time;
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:17,代碼來源:NormalUtil.java

示例3: sendPasswordRecovery

import java.util.Locale; //導入依賴的package包/類
/**
 * Invio la mail per il recupero password
 * @param logoImage e.g. "/res/img/logo-small.jpg"
 * @param yadaRegistrationRequest
 * @param request
 * @param response
 * @param locale
 * @return
 */
public boolean sendPasswordRecovery(YadaRegistrationRequest yadaRegistrationRequest, HttpServletRequest request, Locale locale) {
	final String emailName = "passwordRecovery";
	final String[] toEmail = new String[] {yadaRegistrationRequest.getEmail()};
	final String[] subjectParams = {yadaRegistrationRequest.getEmail()};

	String myServerAddress = yadaWebUtil.getWebappAddress(request);
	String fullLink = myServerAddress + "/passwordReset/" + yadaTokenHandler.makeLink(yadaRegistrationRequest, null);

	final Map<String, Object> templateParams = new HashMap<String, Object>();
	templateParams.put("fullLink", fullLink);
	
	Map<String, String> inlineResources = new HashMap<String, String>();
	inlineResources.put("logosmall", config.getEmailLogoImage());
	return yadaEmailService.sendHtmlEmail(toEmail, emailName, subjectParams, templateParams, inlineResources, locale, true);
}
 
開發者ID:xtianus,項目名稱:yadaframework,代碼行數:25,代碼來源:YadaSecurityEmailService.java

示例4: calculateDifference

import java.util.Locale; //導入依賴的package包/類
private static long[] calculateDifference(long differentMilliSeconds) {
    long secondsInMilli = 1000;//1s==1000ms
    long minutesInMilli = secondsInMilli * 60;
    long hoursInMilli = minutesInMilli * 60;
    long daysInMilli = hoursInMilli * 24;
    long elapsedDays = differentMilliSeconds / daysInMilli;
    differentMilliSeconds = differentMilliSeconds % daysInMilli;
    long elapsedHours = differentMilliSeconds / hoursInMilli;
    differentMilliSeconds = differentMilliSeconds % hoursInMilli;
    long elapsedMinutes = differentMilliSeconds / minutesInMilli;
    differentMilliSeconds = differentMilliSeconds % minutesInMilli;
    long elapsedSeconds = differentMilliSeconds / secondsInMilli;
    LogUtils.verbose(String.format(Locale.CHINA, "different: %d ms, %d days, %d hours, %d minutes, %d seconds",
            differentMilliSeconds, elapsedDays, elapsedHours, elapsedMinutes, elapsedSeconds));
    return new long[]{elapsedDays, elapsedHours, elapsedMinutes, elapsedSeconds};
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:DateUtils.java

示例5: loadSettings

import java.util.Locale; //導入依賴的package包/類
@UsedForTesting
void loadSettings() {
    final Locale locale = mRichImm.getCurrentSubtypeLocale();
    final EditorInfo editorInfo = getCurrentInputEditorInfo();
    final InputAttributes inputAttributes = new InputAttributes(
            editorInfo, isFullscreenMode(), getPackageName());
    mSettings.loadSettings(this, locale, inputAttributes);
    final SettingsValues currentSettingsValues = mSettings.getCurrent();
    AudioAndHapticFeedbackManager.getInstance().onSettingsChanged(currentSettingsValues);
    // This method is called on startup and language switch, before the new layout has
    // been displayed. Opening dictionaries never affects responsivity as dictionaries are
    // asynchronously loaded.
    if (!mHandler.hasPendingReopenDictionaries()) {
        resetDictionaryFacilitator(locale);
    }
    refreshPersonalizationDictionarySession(currentSettingsValues);
    resetDictionaryFacilitatorIfNecessary();
    mStatsUtilsManager.onLoadSettings(this /* context */, currentSettingsValues);
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:20,代碼來源:LatinIME.java

示例6: parseMode

import java.util.Locale; //導入依賴的package包/類
private int parseMode(String mode) throws NoSuchAlgorithmException {
    mode = mode.toUpperCase(Locale.ENGLISH);
    int result;
    if (mode.equals("ECB")) {
        result = MODE_ECB;
    } else if (mode.equals("CBC")) {
        if (blockSize == 0) {
            throw new NoSuchAlgorithmException
                    ("CBC mode not supported with stream ciphers");
        }
        result = MODE_CBC;
    } else if (mode.equals("CTR")) {
        result = MODE_CTR;
    } else {
        throw new NoSuchAlgorithmException("Unsupported mode " + mode);
    }
    return result;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:P11Cipher.java

示例7: main

import java.util.Locale; //導入依賴的package包/類
public static void main(String[] args) {
    for (int cp = 0; cp < Character.MAX_CODE_POINT; cp++) {
        if (!Character.isValidCodePoint(cp)) {
            try {
                Character.getName(cp);
            } catch (IllegalArgumentException x) {
                continue;
            }
            throw new RuntimeException("Invalid failed: " + cp);
        } else if (Character.getType(cp) == Character.UNASSIGNED) {
            if (Character.getName(cp) != null)
                throw new RuntimeException("Unsigned failed: " + cp);
        } else {
            String name = Character.getName(cp);
            if (cp != Character.codePointOf(name) ||
                cp != Character.codePointOf(name.toLowerCase(Locale.ENGLISH)))
            throw new RuntimeException("Roundtrip failed: " + cp);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:CharacterName.java

示例8: getLocales

import java.util.Locale; //導入依賴的package包/類
/**
 * Return the set of preferred Locales that the client will accept
 * content in, based on the values for any <code>Accept-Language</code>
 * headers that were encountered.  If the request did not specify a
 * preferred language, the server's default Locale is returned.
 */
@Override
public Enumeration<Locale> getLocales() {

    if (!localesParsed) {
        parseLocales();
    }

    if (locales.size() > 0) {
        return Collections.enumeration(locales);
    }
    ArrayList<Locale> results = new ArrayList<Locale>();
    results.add(defaultLocale);
    return Collections.enumeration(results);

}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:22,代碼來源:Request.java

示例9: CustomDatePicker

import java.util.Locale; //導入依賴的package包/類
public CustomDatePicker(Context context, ResultHandler resultHandler, String startDate, String endDate) {
    if (isValidDate(startDate, "yyyy-MM-dd HH:mm") && isValidDate(endDate, "yyyy-MM-dd HH:mm")) {
        canAccess = true;
        this.context = context;
        this.handler = resultHandler;
        selectedCalender = Calendar.getInstance();
        startCalendar = Calendar.getInstance();
        endCalendar = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
        try {
            startCalendar.setTime(sdf.parse(startDate));
            endCalendar.setTime(sdf.parse(endDate));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        initDialog();
        initView();
    }
}
 
開發者ID:Jusenr,項目名稱:androidtools,代碼行數:20,代碼來源:CustomDatePicker.java

示例10: testTW

import java.util.Locale; //導入依賴的package包/類
@Test
public void testTW() throws Exception {
    String content = "應用程式資訊: " +
            "處理程序識別碼: 1648 " +
            "應用程式名稱: \\device\\harddiskvolume1\\windows\\system32\\dns.exe " +
            "網路資訊: " +
            "方向: Inbound " +
            "來源位址: 10.42.42.223 " +
            "來源連接埠: 53 " +
            "目的地位址: 10.42.42.123 " +
            "目的地連接埠: 153 " +
            "通訊協定:  6 " +
            "篩選器資訊: " +
            "篩選器執行階段識別碼: 65884 " +
            "階層名稱:  Listen " +
            "階層執行階段識別碼: 40 ";

    Assert.assertNotNull(parse2Map("5156", content, Locale.TAIWAN));
}
 
開發者ID:gazer2kanlin,項目名稱:uia.syslog.we4j,代碼行數:20,代碼來源:WindowsEvent5156Test.java

示例11: getLocaleFromAndroidLangTag

import java.util.Locale; //導入依賴的package包/類
/**
 * There is a method {@link java.util.Locale#forLanguageTag(String)} which would be useful
 * for this, however it doesn't deal with android-specific language tags, which are a little
 * different. For example, android language tags may have an "r" before the country code,
 * such as "zh-rHK", however {@link java.util.Locale} expects them to be "zr-HK".
 */
public static Locale getLocaleFromAndroidLangTag(String languageTag) {
    if (TextUtils.isEmpty(languageTag)) {
        return null;
    }

    final String[] parts = languageTag.split("-");
    if (parts.length == 1) {
        return new Locale(parts[0]);
    }
    if (parts.length == 2) {
        String country = parts[1];
        // Some languages have an "r" before the country as per the values folders, such
        // as "zh-rCN". As far as the Locale class is concerned, the "r" is
        // not helpful, and this should be "zh-CN". Thus, we will
        // strip the "r" when found.
        if (country.charAt(0) == 'r' && country.length() == 3) {
            country = country.substring(1);
        }
        return new Locale(parts[0], country);
    }
    Log.e(TAG, "Locale could not be parsed from language tag: " + languageTag);
    return new Locale(languageTag);
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:30,代碼來源:Utils.java

示例12: apply

import java.util.Locale; //導入依賴的package包/類
@Override
public void apply(Settings.Builder settingsBuilder, Object[] parameters, Expression expression) {
    ByteSizeValue byteSizeValue;
    try {
        byteSizeValue = ExpressionToByteSizeValueVisitor.convert(expression, parameters);
    } catch (IllegalArgumentException e) {
        throw invalidException(e);
    }

    if (byteSizeValue == null) {
        throw new IllegalArgumentException(String.format(Locale.ENGLISH,
                "'%s' does not support null values", name));
    }

    applyValue(settingsBuilder, byteSizeValue);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:17,代碼來源:SettingsAppliers.java

示例13: toZid

import java.util.Locale; //導入依賴的package包/類
public static String toZid(String zid, Locale locale) {
    String mzone = zidToMzone.get(zid);
    if (mzone == null && aliases.containsKey(zid)) {
        zid = aliases.get(zid);
        mzone = zidToMzone.get(zid);
    }
    if (mzone != null) {
        Map<String, String> map = mzoneToZidL.get(mzone);
        if (map != null && map.containsKey(locale.getCountry())) {
            zid = map.get(locale.getCountry());
        } else {
            zid = mzoneToZid.get(mzone);
        }
    }
    return toZid(zid);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:17,代碼來源:ZoneName.java

示例14: setLocale

import java.util.Locale; //導入依賴的package包/類
/**
 * Sets the locale of this context. <code>VetoableChangeListener</code>s
 * and <code>PropertyChangeListener</code>s are notified.
 * 
 * @param newLocale     the new locale to set
 * @throws PropertyVetoException if any <code>VetoableChangeListener</code> vetos this change
 */
public void setLocale(Locale newLocale) throws PropertyVetoException {
    if (newLocale == null || newLocale == locale) {
        return; // ignore null locale
    }

    PropertyChangeEvent event = new PropertyChangeEvent(
            beanContextChildPeer, "locale", locale, newLocale);

    // apply change
    Locale oldLocale = locale;
    locale = newLocale;

    try {
        // notify vetoable listeners
        vcSupport.fireVetoableChange(event);
    } catch (PropertyVetoException e) {
        // rollback change
        locale = oldLocale;
        throw e;
    }
    // Notify BeanContext about this change
    this.pcSupport.firePropertyChange(event);
}
 
開發者ID:yippeesoft,項目名稱:NotifyTools,代碼行數:31,代碼來源:BeanContextSupport.java

示例15: getLocaleFileNames

import java.util.Locale; //導入依賴的package包/類
/**
 * Gets a list containing the names of all possible message files
 * for a locale.
 *
 * @param prefix The file name prefix.
 * @param suffix The file name suffix.
 * @param locale The {@code Locale} to generate file names for.
 * @return A list of candidate file names.
 */
public static List<String> getLocaleFileNames(String prefix,
                                              String suffix,
                                              Locale locale) {
    String language = locale.getLanguage();
    String country = locale.getCountry();
    String variant = locale.getVariant();

    List<String> result = new ArrayList<>(4);

    if (!language.isEmpty()) language = "_" + language;
    if (!country.isEmpty()) country = "_" + country;
    if (!variant.isEmpty()) variant = "_" + variant;

    result.add(prefix + suffix);
    String filename = prefix + language + suffix;
    if (!result.contains(filename)) result.add(filename);
    filename = prefix + language + country + suffix;
    if (!result.contains(filename)) result.add(filename);
    filename = prefix + language + country + variant + suffix;
    if (!result.contains(filename)) result.add(filename);
    return result;
}
 
開發者ID:wintertime,項目名稱:FreeCol,代碼行數:32,代碼來源:FreeColDirectories.java


注:本文中的java.util.Locale類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。