Example usage for java.util Locale UK

List of usage examples for java.util Locale UK

Introduction

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

Prototype

Locale UK

To view the source code for java.util Locale UK.

Click Source Link

Document

Useful constant for country.

Usage

From source file:org.opendatakit.utilities.LocalizationUtilsTest.java

@Test
public void testNormalizeDisplayName() throws JsonProcessingException {
    Map<String, Object> langMap = new TreeMap<String, Object>();
    langMap.put("en_US", "This is a test");
    langMap.put("en_GB", "Test is This");
    langMap.put("en", "Huh Test");
    langMap.put("fr", "Je suis");
    langMap.put("default", "No way!");
    Map<String, Object> topMap = new TreeMap<String, Object>();
    topMap.put("text", langMap);
    String value = ODKFileUtils.mapper.writeValueAsString(topMap);

    Locale defaultLocale;//from w ww  .j  ava2  s.  c  om
    String full_locale;
    String match;

    Locale.setDefault(Locale.US);
    defaultLocale = Locale.getDefault();
    full_locale = defaultLocale.getLanguage() + "_" + defaultLocale.getCountry();
    match = LocalizationUtils.getLocalizedDisplayName(appName, tableId, full_locale, value);
    assertEquals("This is a test", match);

    Locale.setDefault(Locale.UK);
    defaultLocale = Locale.getDefault();
    full_locale = defaultLocale.getLanguage() + "_" + defaultLocale.getCountry();
    match = LocalizationUtils.getLocalizedDisplayName(appName, tableId, full_locale, value);
    assertEquals("Test is This", match);

    Locale.setDefault(Locale.CANADA);
    defaultLocale = Locale.getDefault();
    full_locale = defaultLocale.getLanguage() + "_" + defaultLocale.getCountry();
    match = LocalizationUtils.getLocalizedDisplayName(appName, tableId, full_locale, value);
    assertEquals("Huh Test", match);

    Locale.setDefault(Locale.CANADA_FRENCH);
    defaultLocale = Locale.getDefault();
    full_locale = defaultLocale.getLanguage() + "_" + defaultLocale.getCountry();
    match = LocalizationUtils.getLocalizedDisplayName(appName, tableId, full_locale, value);
    assertEquals("Je suis", match);

    Locale.setDefault(Locale.GERMANY);
    defaultLocale = Locale.getDefault();
    full_locale = defaultLocale.getLanguage() + "_" + defaultLocale.getCountry();
    match = LocalizationUtils.getLocalizedDisplayName(appName, tableId, full_locale, value);
    assertEquals("No way!", match);

    Locale.setDefault(Locale.US);
}

From source file:org.powertac.producer.pvfarm.IrradianceModelTest.java

@Test
public void testGetAirMass() throws IOException {
    File file = new File("data/dataGetAirMass.txt");
    file.createNewFile();// ww  w .j  av  a  2s  .c  o  m
    PrintWriter pw = new PrintWriter(new File("data/dataGetAirMass.txt"));
    for (double g = 0; g < 91; g++) {
        double data = IrradianceModel.getAirMass(g);
        pw.printf(Locale.UK, "%f,%f%n", g, data);
        if (g == 0.0) {
            assertEquals(38, data, 0.5);
        } else if (g == 90.0) {
            assertEquals(1, data, 0.01);
        }
    }
    pw.close();
}

From source file:com.android.medisolv.RegistrationActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_registration);

    mobile = (EditText) findViewById(R.id.mobile_no);

    firstName = (EditText) findViewById(R.id.reg_fn);
    lastName = (EditText) findViewById(R.id.reg_ln);
    email = (EditText) findViewById(R.id.reg_email);
    mobile = (EditText) findViewById(R.id.reg_mobile);

    /*code to set date picker*/
    dateFormatter = new SimpleDateFormat("dd-MMM-yyyy", Locale.UK);
    dob = (EditText) findViewById(R.id.reg_dob);
    addListenerOnButton();/*from www.j  a v  a2 s.c o  m*/

    /*code to set custom title bar*/
    Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
    setSupportActionBar(myToolbar);

    /*set spinner values*/
    spinner = (Spinner) findViewById(R.id.spinner1);
    ArrayAdapter arrayAdapter = ArrayAdapter.createFromResource(this, R.array.spinner1_array,
            R.layout.support_simple_spinner_dropdown_item);
    spinner.setAdapter(arrayAdapter);

    /*set gender spinner values*/
    genderSpinner = (Spinner) findViewById(R.id.genderSpinner);
    ArrayAdapter genderArrayAdapter = ArrayAdapter.createFromResource(this, R.array.gender_array,
            R.layout.support_simple_spinner_dropdown_item);
    genderSpinner.setAdapter(genderArrayAdapter);

    /* set Registration Type spinner values*/
    regTypeSpinner = (Spinner) findViewById(R.id.regTypeSpinner);
    ArrayAdapter regTypeArrayAdapter = ArrayAdapter.createFromResource(this, R.array.regType_array,
            R.layout.support_simple_spinner_dropdown_item);
    regTypeSpinner.setAdapter(regTypeArrayAdapter);

    spinner.setOnItemSelectedListener(this);
    genderSpinner.setOnItemSelectedListener(this);
    regTypeSpinner.setOnItemSelectedListener(this);

    submit = (Button) findViewById(R.id.submit);
    submit.setOnClickListener(new View.OnClickListener() {

        @Override

        public void onClick(View v) {

            String enteredFirstName = firstName.getText().toString();

            String enteredLastName = lastName.getText().toString();

            String name = enteredFirstName + " " + enteredLastName;

            String enteredEmail = email.getText().toString().trim();

            String enteredMobile = mobile.getText().toString();

            String selectedGender = genderSpinner.getSelectedItem().toString();

            String enteredDob = dob.getText().toString();

            String selectedRegType = regTypeSpinner.getSelectedItem().toString();

            String enteredLicense = license.getText().toString();

            String enteredSpecialization = specialisation.getText().toString();

            String salute = spinner.getSelectedItem().toString();

            String emailPattern = "[a-zA-Z0-9._-]+@[a-z]+\\.+[a-z]+";

            String changedFormatDob = "";

            try {
                Date dobDate = dateFormatter.parse(enteredDob);
                changeDateFormatter = new SimpleDateFormat("yyyy/mm/dd", Locale.UK);
                changedFormatDob = changeDateFormatter.format(dobDate);
                System.out.println("Changed date: " + changedFormatDob);
            } catch (ParseException e) {
                e.printStackTrace();
            }

            if (enteredFirstName.equals("") || enteredLastName.equals("") || enteredEmail.equals("")
                    || enteredMobile.equals("") || selectedGender.equals("") || selectedRegType.equals("")
                    || changedFormatDob.equals("") || salute.equals("") || enteredEmail.equals("")) {

                Toast.makeText(RegistrationActivity.this, "All fields are mandatory", Toast.LENGTH_LONG).show();

                return;

            } else if (selectedRegType.equals("Doctor")
                    && (enteredLicense.equals("") || enteredSpecialization.equals(""))) {

                Toast.makeText(RegistrationActivity.this, "All fields are mandatory", Toast.LENGTH_LONG).show();

                return;

            } else if (enteredMobile.length() < 10) {
                Toast.makeText(RegistrationActivity.this, "Mobile Number should be 10 digits",
                        Toast.LENGTH_LONG).show();
                return;
            }

            else if (enteredEmail.matches(emailPattern) == false) {
                System.out.println("Invalid Email");
                Toast.makeText(RegistrationActivity.this, "Please enter the valid Email Address",
                        Toast.LENGTH_LONG).show();
                return;
            }
            // request authentication with remote server4
            else {
                RegistrationActivityAsyncTask asyncRequestObject = new RegistrationActivityAsyncTask();

                asyncRequestObject.execute(serverUrl, salute, name, enteredMobile, enteredEmail, selectedGender,
                        changedFormatDob, selectedRegType, enteredLicense, enteredSpecialization);
            }
        }

    });

}

From source file:com.github.mrstampy.gameboot.messages.context.GameBootContextTest.java

/**
 * Test intl./*from www  .j  a  v  a2  s  .  c o m*/
 *
 * @throws Exception
 *           the exception
 */
@Test
public void testIntl() throws Exception {
    ResponseContext rc = lookup.lookup(UNEXPECTED_ERROR, Locale.getDefault());
    assertRC(rc, UNEXPECTED_ERROR, DEFAULT);

    rc = lookup.lookup(UNEXPECTED_ERROR, Locale.FRENCH);
    assertRC(rc, UNEXPECTED_ERROR, FRENCH);

    rc = lookup.lookup(UNEXPECTED_ERROR, Locale.UK);
    assertRC(rc, UNEXPECTED_ERROR, DEFAULT);

    rc = lookup.lookup(UNEXPECTED_ERROR, new Locale("r2", "D2"));
    assertRC(rc, UNEXPECTED_ERROR, DEFAULT);
}

From source file:org.adeptnet.atlassian.common.AuthenticatorInterface.java

default public Principal getUserCommon(final HttpServletRequest request, final HttpServletResponse response) {
    final Principal userSession = getUserFromSession(request);
    if (userSession != null) {
        return userSession;
    }//w  w w.  ja v a  2  s . co  m

    final Common common = getCommon();

    final String krb5User = common.getKrb5UserName(request);
    if (krb5User != null) {
        return getUserFromUserName(request, response, krb5User, "KRB5");
    }

    final String samlUser = common.getSAMLUserName(request);
    if (samlUser != null) {
        return getUserFromUserName(request, response, samlUser, "SAML");
    }

    if (response == null) {
        return null;
    }

    if (common.isKrb5Enabled()) {
        final String uri = request.getRequestURI().toLowerCase(Locale.UK);
        if (!common.krb5Skip401(uri)) {
            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
        }
        response.setHeader(Krb5.WWW_AUTHENTICATE, Krb5.NEGOTIATE);
    }

    return null;
}

From source file:org.jfree.data.time.DayTest.java

/**
 * In GMT, the end of 29 Feb 2004 is java.util.Date(1,078,099,199,999L).
 * Use this to check the day constructor.
 *//*from   ww  w. ja  v  a2s .  c  o  m*/
@Test
public void testDateConstructor1() {
    TimeZone zone = TimeZone.getTimeZone("GMT");
    Locale locale = Locale.UK;
    Day d1 = new Day(new Date(1078099199999L), zone, locale);
    Day d2 = new Day(new Date(1078099200000L), zone, locale);

    assertEquals(MonthConstants.FEBRUARY, d1.getMonth());
    assertEquals(1078099199999L, d1.getLastMillisecond(zone));

    assertEquals(MonthConstants.MARCH, d2.getMonth());
    assertEquals(1078099200000L, d2.getFirstMillisecond(zone));
}

From source file:org.richfaces.component.CalendarComponentTest.java

public void setUp() throws Exception {

    super.setUp();

    form = new HtmlForm();
    form.setId("form");
    facesContext.getViewRoot().getChildren().add(form);
    calendar = (UICalendar) application.createComponent(UICalendar.COMPONENT_TYPE);
    calendar1 = (UICalendar) application.createComponent(UICalendar.COMPONENT_TYPE);
    calendar.setLocale(Locale.UK);
    calendar.setDatePattern("d/MM/yyyy");
    calendar.setTimeZone(TimeZone.getTimeZone("GMT-4:00"));

    calendar.setButtonLabel("PopUp");
    // XXX test popup false
    // XXX test CurrentDate = null
    calendar.setPopup(true);/*from   w w w . j  a v a 2s  .  c  o  m*/
    Calendar calendarObject = Calendar.getInstance();
    calendarObject.clear();
    calendarObject.set(2001, Calendar.SEPTEMBER, 11, 10, 0, 0);
    calendar.setId("calendar");
    calendar.setValue(calendarObject.getTime());
    form.getChildren().add(calendar);
    calendar1.setId("_calendar");
    calendar1.setPopup(false);
    calendar1.setCurrentDate(null);
    form.getChildren().add(calendar1);

    calendar2 = (UICalendar) application.createComponent(UICalendar.COMPONENT_TYPE);
    calendar2.setDatePattern("dd/M/yy HH:mm");
    calendarObject.set(2001, Calendar.SEPTEMBER, 11, 13, 36);
    calendar2.setValue(calendarObject.getTime());
    calendar2.setId("timecalendar");
    form.getChildren().add(calendar2);

    calendar3 = (UICalendar) application.createComponent(UICalendar.COMPONENT_TYPE);
    calendar3.setDatePattern("dd/M/yy HH:mm");
    calendarObject.set(2001, Calendar.SEPTEMBER, 11, 13, 36);
    calendar3.setValue(calendarObject.getTime());
    calendar3.setId("timecalendar");
    calendar3.setMode(UICalendar.AJAX_MODE);
    calendar3.setLocale(new Locale("ru", "RU", ""));
    calendar3.setCellHeight("50");
    calendar3.setCellWidth("50");
    form.getChildren().add(calendar3);
}

From source file:com.bt.aloha.dialog.DigestClientAuthenticationMethod.java

public String generateResponse(String realm, String userName, String uri, String nonce, String password,
        String method, String cnonce, String algorithm) {
    LOG.debug(String.format("generateResponse(%s, %s, %s, %s, %s, %s, %s, %s)", realm, userName, uri, nonce,
            password, method, cnonce, algorithm));

    if (algorithm == null)
        throw new StackException("The algorithm parameter is null");
    MessageDigest messageDigest;/*from w  w w.j  a v a  2 s  . com*/
    try {
        messageDigest = MessageDigest.getInstance(algorithm);
    } catch (NoSuchAlgorithmException ex) {
        throw new StackException(String.format("ERROR: %s digest algorithm does not exist.", algorithm));
    }

    StringBuffer buffer = new StringBuffer();

    // A1
    if (userName != null)
        buffer.append(userName);
    buffer.append(COLON);
    if (realm != null)
        buffer.append(realm);
    buffer.append(COLON);
    if (password != null)
        buffer.append(password);

    String A1 = buffer.toString();
    byte[] mdbytes = messageDigest.digest(A1.getBytes());
    String HA1 = toHexString(mdbytes);
    LOG.debug(String.format("HA1: %s", HA1));

    // A2
    buffer = new StringBuffer();
    if (method != null)
        buffer.append(method.toUpperCase(Locale.UK));
    buffer.append(COLON);
    if (uri != null)
        buffer.append(uri);
    String A2 = buffer.toString();
    mdbytes = messageDigest.digest(A2.getBytes());
    String HA2 = toHexString(mdbytes);
    LOG.debug(String.format("HA2: %s", HA2));

    // KD
    buffer = new StringBuffer();
    buffer.append(HA1 + COLON);
    if (nonce != null)
        buffer.append(nonce);
    if (cnonce != null) {
        if (cnonce.length() > 0)
            buffer.append(COLON + cnonce);
    }
    buffer.append(COLON + HA2);
    String KD = buffer.toString();

    mdbytes = messageDigest.digest(KD.getBytes());
    String response = toHexString(mdbytes);

    LOG.debug(String.format("response generated: %s", response));

    return response;
}

From source file:org.pac4j.oauth.client.TwitterClientIT.java

@Override
protected void verifyProfile(final UserProfile userProfile) {
    final TwitterProfile profile = (TwitterProfile) userProfile;
    logger.debug("userProfile : {}", profile);
    assertEquals("488358057", profile.getId());
    assertEquals(TwitterProfile.class.getSimpleName() + UserProfile.SEPARATOR + "488358057",
            profile.getTypedId());//from   w  w  w . j  av a2s  .  co m
    assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), TwitterProfile.class));
    assertTrue(StringUtils.isNotBlank(profile.getAccessToken()));
    assertCommonProfile(userProfile, null, null, null, "test scribeUP", "testscribeUP", Gender.UNSPECIFIED,
            Locale.UK, ".twimg.com/sticky/default_profile_images/default_profile_5_normal.png",
            "http://t.co/fNjYqp7wZ8", "New York");
    assertFalse(profile.getContributorsEnabled());
    assertEquals(TestsHelper.getFormattedDate(1328872224000L, "EEE MMM dd HH:mm:ss Z yyyy", Locale.US),
            profile.getCreatedAt().toString());
    assertTrue(profile.getDefaultProfile());
    assertTrue(profile.getDefaultProfileImage());
    assertEquals("biographie", profile.getDescription());
    assertEquals(0, profile.getFavouritesCount().intValue());
    assertFalse(profile.getFollowRequestSent());
    assertEquals(0, profile.getFollowersCount().intValue());
    assertFalse(profile.getFollowing());
    assertEquals(0, profile.getFriendsCount().intValue());
    assertFalse(profile.getGeoEnabled());
    assertFalse(profile.getIsTranslator());
    assertEquals(0, profile.getListedCount().intValue());
    assertFalse(profile.getNotifications());
    assertTrue(profile.getProfileBackgroundColor() instanceof Color);
    assertTrue(profile.getProfileBackgroundImageUrl().contains(".twimg.com/images/themes/theme1/bg.png"));
    assertTrue(profile.getProfileBackgroundImageUrlHttps().endsWith("/images/themes/theme1/bg.png"));
    assertFalse(profile.getProfileBackgroundTile());
    assertTrue(profile.getProfileImageUrlHttps()
            .endsWith("/sticky/default_profile_images/default_profile_5_normal.png"));
    assertTrue(profile.getProfileLinkColor() instanceof Color);
    assertTrue(profile.getProfileSidebarBorderColor() instanceof Color);
    assertTrue(profile.getProfileSidebarFillColor() instanceof Color);
    assertTrue(profile.getProfileTextColor() instanceof Color);
    assertTrue(profile.getProfileUseBackgroundImage());
    assertTrue(profile.getProtected());
    assertNull(profile.getShowAllInlineMedia());
    assertEquals(0, profile.getStatusesCount().intValue());
    assertEquals("Amsterdam", profile.getTimeZone());
    assertEquals(7200, profile.getUtcOffset().intValue());
    assertFalse(profile.getVerified());
    assertNotNull(profile.getAccessSecret());
    assertEquals(37, profile.getAttributes().size());
}

From source file:org.opendatakit.common.android.utilities.ODKDataUtilsTest.java

@Test
public void testNormalizeDisplayName2() {
    Map<String, Object> langMap = new TreeMap<String, Object>();
    langMap.put("en_US", "This is a test");
    langMap.put("en_GB", "Test is This");
    langMap.put("en", "Huh Test");
    langMap.put("fr", "Je suis");
    langMap.put("default", "No way!");

    String match;// ww  w. j a v  a2s . c om

    Locale.setDefault(Locale.US);
    match = ODKDataUtils.getLocalizedDisplayName(langMap);
    assertEquals("This is a test", match);

    Locale.setDefault(Locale.UK);
    match = ODKDataUtils.getLocalizedDisplayName(langMap);
    assertEquals("Test is This", match);

    Locale.setDefault(Locale.CANADA);
    match = ODKDataUtils.getLocalizedDisplayName(langMap);
    assertEquals("Huh Test", match);

    Locale.setDefault(Locale.CANADA_FRENCH);
    match = ODKDataUtils.getLocalizedDisplayName(langMap);
    assertEquals("Je suis", match);

    Locale.setDefault(Locale.GERMANY);
    match = ODKDataUtils.getLocalizedDisplayName(langMap);
    assertEquals("No way!", match);

    Locale.setDefault(Locale.US);
}