Search in sources :

Example 76 with Locale

use of java.util.Locale in project hadoop by apache.

the class TestFSDownload method testDownloadArchiveZipWithTurkishLocale.

/*
   * To test fix for YARN-3029
   */
@Test(timeout = 10000)
public void testDownloadArchiveZipWithTurkishLocale() throws IOException, URISyntaxException, InterruptedException {
    Locale defaultLocale = Locale.getDefault();
    // Set to Turkish
    Locale turkishLocale = new Locale("tr", "TR");
    Locale.setDefault(turkishLocale);
    downloadWithFileType(TEST_FILE_TYPE.ZIP);
    // Set the locale back to original default locale
    Locale.setDefault(defaultLocale);
}
Also used : Locale(java.util.Locale) Test(org.junit.Test)

Example 77 with Locale

use of java.util.Locale in project SeriesGuide by UweTrottmann.

the class MovieLocalizationDialogFragment method updateButtonText.

private void updateButtonText() {
    // example: "en-US"
    String languageCode = DisplaySettings.getMoviesLanguage(getContext());
    String languageDisplayName = new Locale(languageCode.substring(0, 2), languageCode.substring(3)).getDisplayName();
    buttonLanguage.setText(languageDisplayName);
    String regionCode = DisplaySettings.getMoviesRegion(getContext());
    buttonRegion.setText(new Locale("", regionCode).getDisplayCountry());
}
Also used : Locale(java.util.Locale)

Example 78 with Locale

use of java.util.Locale in project SeriesGuide by UweTrottmann.

the class LanguageTools method getMovieLanguageData.

/**
     * Returns the string representation and index of the given two letter ISO 639-1 language code
     * plus an extra ISO-3166-1 region tag used by TMDB currently set by {@link
     * DisplaySettings#getMoviesLanguage(Context)}.
     */
@Nullable
public static LanguageData getMovieLanguageData(Context context) {
    String languageCodeCurrent = DisplaySettings.getMoviesLanguage(context);
    String[] languageCodes = context.getResources().getStringArray(R.array.languageCodesMovies);
    for (int i = 0; i < languageCodes.length; i++) {
        String languageCode = languageCodes[i];
        if (languageCode.equals(languageCodeCurrent)) {
            String languageDisplayName = new Locale(languageCode.substring(0, 2), languageCode.substring(3)).getDisplayName();
            return new LanguageData(i, languageCode, languageDisplayName);
        }
    }
    return null;
}
Also used : Locale(java.util.Locale) Nullable(android.support.annotation.Nullable)

Example 79 with Locale

use of java.util.Locale in project NewPipe by TeamNewPipe.

the class Localization method formatDate.

private static String formatDate(String date, Context context) {
    Locale locale = getPreferredLocale(context);
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
    Date datum = null;
    try {
        datum = formatter.parse(date);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
    return df.format(datum);
}
Also used : Locale(java.util.Locale) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 80 with Locale

use of java.util.Locale in project NewPipe by TeamNewPipe.

the class Localization method localizeViewCount.

public static String localizeViewCount(long viewCount, Context context) {
    Locale locale = getPreferredLocale(context);
    Resources res = context.getResources();
    String viewsString = res.getString(R.string.view_count_text);
    NumberFormat nf = NumberFormat.getInstance(locale);
    String formattedViewCount = nf.format(viewCount);
    return String.format(viewsString, formattedViewCount);
}
Also used : Locale(java.util.Locale) Resources(android.content.res.Resources) NumberFormat(java.text.NumberFormat)

Aggregations

Locale (java.util.Locale)5854 Test (org.junit.Test)902 HashMap (java.util.HashMap)548 GenericValue (org.apache.ofbiz.entity.GenericValue)504 ArrayList (java.util.ArrayList)486 Delegator (org.apache.ofbiz.entity.Delegator)484 GenericEntityException (org.apache.ofbiz.entity.GenericEntityException)398 IOException (java.io.IOException)313 LocalDispatcher (org.apache.ofbiz.service.LocalDispatcher)296 Date (java.util.Date)273 GenericServiceException (org.apache.ofbiz.service.GenericServiceException)271 Map (java.util.Map)244 BigDecimal (java.math.BigDecimal)214 SimpleDateFormat (java.text.SimpleDateFormat)198 ResourceBundle (java.util.ResourceBundle)197 File (java.io.File)166 LinkedList (java.util.LinkedList)158 ULocale (android.icu.util.ULocale)156 List (java.util.List)147 Test (org.junit.jupiter.api.Test)132