Package com.ibm.icu.util

Examples of com.ibm.icu.util.ULocale


  // Some locales use localized digits and so even a simple pattern will be formatted
  // differently than in English.
  // The following is a simple example for Hindi.
  public void testHindiLocale() {
    ValueFormatter dateFormatter = ValueFormatter.createFromPattern(
        ValueType.DATE, "MM | dd | yyyy", new ULocale("hi_IN"));
    DateValue dateValue = new DateValue(2009, 1, 2);
    String dateString =
        "\u0966\u0968\u0020\u007c\u0020\u0966\u0968\u0020\u007c\u0020\u0968\u0966\u0966\u096f";
    assertEquals(dateString, dateFormatter.format(dateValue));
    assertEquals(dateValue, dateFormatter.parse(dateString));
View Full Code Here


  /*
   * Create a locale from localeID.
   * Then return the appropriate collator for the locale.
   */
  private Collator createFromLocale(String localeID) {
    return Collator.getInstance(new ULocale(localeID));
  }
View Full Code Here

   *
   * The default is DIN 5007-1, this shows how to tailor a collator to get DIN 5007-2 behavior.
   *  http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4423383
   */
  public void testCustomRules() throws Exception {
    RuleBasedCollator baseCollator = (RuleBasedCollator) Collator.getInstance(new ULocale("de_DE"));

    String DIN5007_2_tailorings =
      "& ae , a\u0308 & AE , A\u0308"+
      "& oe , o\u0308 & OE , O\u0308"+
      "& ue , u\u0308 & UE , u\u0308";
View Full Code Here

        ArrayList<ULocale> ulocales = new ArrayList<ULocale>();
        for (String locale : locales) {
            if (locale != null) {
                try {
                    ULocale ulocale = ULocale.forLanguageTag(locale);
                    if (!ulocale.getLanguage().equals(""))
                        ulocales.add(ulocale);
                } catch (Exception e) {
                    // There can be intermittent problems with the internal
                    // functioning of the ULocale class with some
                    // language tags; best to just log these and continue
View Full Code Here

     * @param tag
     * @return true if a valid language tag, otherwise false
     */
    public static boolean isValidLanguageTag(String tag) {
        try {
            ULocale locale = ULocale.forLanguageTag(tag);
            if (locale.toLanguageTag() == null) {
                return false;
        }
            // We don't accept "x" extensions (private use tags)
            if (locale.getExtension("x".charAt(0)) != null) {
                return false;
        }
            if (!locale.toLanguageTag().equalsIgnoreCase(tag)) {
                return false;
        }
            return true;
        } catch (Exception e) {
            return false;
View Full Code Here

            languageCode = "";
            countryCode = "";
            variantCode = variant;
            return;
        }
        this.uLocale = new ULocale(language, country, variant);
        languageCode = uLocale.getLanguage();
        // Map new language codes to the obsolete language
        // codes so the correct resource bundles will be used.
        if (languageCode.equals("he")) {//$NON-NLS-1$
            languageCode = "iw"; //$NON-NLS-1$
View Full Code Here

    private void expect(String[] data, int data_length) {
        int i = 1;
        while (i<data_length) {
            String locName = data[i++];
            ULocale loc = new ULocale(locName);
            SimpleDateFormat ref = new SimpleDateFormat(data[0], loc);
            // 'f'
            String datestr = data[i++];
            String datestr_2 = data[i++];
            Date date, date_2;
View Full Code Here

   
    private void expectUserDII(String[] data, int data_length) {
        int i = 1;
        while (i<data_length) {
            String locName = data[i++];
            ULocale loc = new ULocale(locName);
            SimpleDateFormat ref = new SimpleDateFormat(data[0], loc);
            // 'f'
            String datestr = data[i++];
            String datestr_2 = data[i++];
            Date date, date_2;
View Full Code Here

   
    private void expectUserCLDR(String[] data, int data_length) {
        int i = 1;
        while (i<data_length) {
            String locName = data[i++];
            ULocale loc = new ULocale(locName);
            SimpleDateFormat ref = new SimpleDateFormat(data[0], loc);
            // 'f'
            String datestr = data[i++];
            String datestr_2 = data[i++];
            Date date, date_2;
View Full Code Here

    /*
     * Ticket#6396 DateIntervalInfo of ICU4J 4.0d3 throw NullPointerException
     */
    public void TestT6396() {
        DateIntervalInfo dii = new DateIntervalInfo(new ULocale("th_TH"));
        try {
            // ticket#6396 reported toString() throws NullPointerException
            String diiStr = dii.toString();
            logln("new DateIntervalInfo(new ULocale(\"th_TH\")).toString() - " + diiStr);

View Full Code Here

TOP

Related Classes of com.ibm.icu.util.ULocale

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.