当前位置: 首页>>代码示例>>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;未经允许,请勿转载。