Example usage for java.util Locale Locale

List of usage examples for java.util Locale Locale

Introduction

In this page you can find the example usage for java.util Locale Locale.

Prototype

public Locale(String language) 

Source Link

Document

Construct a locale from a language code.

Usage

From source file:fi.helsinki.opintoni.service.NewsServiceCacheTest.java

@Test
public void thatStudentNewsAreCached() {
    flammaServer.expectStudentNews();/*from   ww  w  . j  av a  2s  .  c  om*/

    List<NewsDto> news = newsService.getStudentNews(new Locale("fi"));
    List<NewsDto> cachedNews = newsService.getStudentNews(new Locale("fi"));

    assertThat(cachedNews).isSameAs(news);
}

From source file:com.inkubator.hrm.web.converter.MonthNumberAsStringConverter.java

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
    String monthAsString = StringUtils.EMPTY;
    String data = value.toString();

    if (StringUtils.isNumeric(data)) {
        Integer month = Integer.valueOf(data);
        DateFormatSymbols dfs = new DateFormatSymbols(
                new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()));
        monthAsString = dfs.getMonths()[month - 1];
    }/*from  www .ja va2s.  co  m*/

    return monthAsString;
}

From source file:modelinspector.collectors.RequireAllCollector.java

public RequireAllCollector(String aName, String aLanguage, boolean aCaseSensitive, String... aTokens) {
    name = aName;/*from w w  w  .jav a  2  s  .c om*/
    required = new HashSet<String>();
    language = new Locale(aLanguage);
    caseSensitive = aCaseSensitive;

    for (String t : aTokens) {
        required.add(caseSensitive ? t : t.toLowerCase(language));
    }
}

From source file:com.cburch.logisim.util.LocaleManager.java

public static void setLocale(Locale loc) {
    Locale cur = getLocale();//from  w w w. ja  va  2  s.  c o m
    if (!loc.equals(cur)) {
        Locale[] opts = LocaleString.getUtilLocaleManager().getLocaleOptions();
        Locale select = null;
        Locale backup = null;
        String locLang = loc.getLanguage();
        for (Locale opt : opts) {
            if (select == null && opt.equals(loc)) {
                select = opt;
            }
            if (backup == null && opt.getLanguage().equals(locLang)) {
                backup = opt;
            }
        }
        if (select == null) {
            if (backup == null) {
                select = new Locale("en");
            } else {
                select = backup;
            }
        }

        curLocale = select;
        Locale.setDefault(select);
        for (LocaleManager man : managers) {
            man.loadDefault();
        }
        repl = replaceAccents ? fetchReplaceAccents() : null;
        fireLocaleChanged();
    }
}

From source file:org.openhie.openempi.util.ConvertUtilTest.java

public void testGetInternationalDatePattern() {
    LocaleContextHolder.setLocale(new Locale("nl"));
    assertEquals("dd-MMM-yyyy", DateUtil.getDatePattern());

    LocaleContextHolder.setLocale(Locale.FRANCE);
    assertEquals("dd/MM/yyyy", DateUtil.getDatePattern());

    LocaleContextHolder.setLocale(Locale.GERMANY);
    assertEquals("dd.MM.yyyy", DateUtil.getDatePattern());

    // non-existant bundle should default to default locale
    LocaleContextHolder.setLocale(new Locale("fi"));
    String fiPattern = DateUtil.getDatePattern();
    LocaleContextHolder.setLocale(Locale.getDefault());
    String defaultPattern = DateUtil.getDatePattern();

    assertEquals(defaultPattern, fiPattern);
}

From source file:com.joliciel.jochre.yiddish.JochreYiddish.java

public JochreYiddish() {
    super(new Locale("yi"));
}

From source file:net.sourceforge.vulcan.web.XslHelper.java

public XslHelper(String locale) {
    this.locale = new Locale(locale);
}

From source file:com.isalnikov.config.MessageTest.java

@Test
public void testRuTextConfigurer() {
    System.out.println(messageHelper.getMessage(new Locale("ru"), "loginController.logout"));
    System.out.println(messageHelper.getMessage(new Locale("ru_RU"), "loginController.logout"));
}

From source file:fi.helsinki.opintoni.util.CoursePageUriBuilderTest.java

@Test
public void thatEnglishUrisAreLocalized() {
    LocaleContextHolder.setLocale(new Locale("en"));

    CoursePageCourseImplementation coursePage = createCoursePage();
    assertThat(coursePageUriBuilder.getLocalizedUri(coursePage)).isEqualTo("http://courses.helsinki.fi/123");
}

From source file:no.dusken.aranea.admin.editor.CalendarEditor.java

@Override
public void setAsText(String string) throws IllegalArgumentException {

    DateFormat formatter = new SimpleDateFormat(format, new Locale("no"));
    Date date;/* w  ww  .  j  a  v a2s.c o  m*/
    try {
        date = formatter.parse(string);
    } catch (ParseException e) {
        throw new IllegalArgumentException("Not in right format: " + format);
    }

    Calendar cal = new GregorianCalendar();
    cal.setTime(date);
    setValue(cal);
}