Example usage for java.util Locale US

List of usage examples for java.util Locale US

Introduction

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

Prototype

Locale US

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

Click Source Link

Document

Useful constant for country.

Usage

From source file:Main.java

/** Recupera el valor de un RDN (<i>Relative Distinguished Name</i>) de un principal. El valor de retorno no incluye
 * el nombre del RDN, el igual, ni las posibles comillas que envuelvan el valor.
 * La funci&oacute;n no es sensible a la capitalizaci&oacute;n del RDN. Si no se
 * encuentra, se devuelve {@code null}.//from  w  w  w.ja  v a 2 s  . c om
 * @param rdn RDN que deseamos encontrar.
 * @param principal Principal del que extraer el RDN (seg&uacute;n la <a href="http://www.ietf.org/rfc/rfc4514.txt">RFC 4514</a>).
 * @return Valor del RDN indicado o {@code null} si no se encuentra. */
public static String getRDNvalueFromLdapName(final String rdn, final String principal) {

    int offset1 = 0;
    while ((offset1 = principal.toLowerCase(Locale.US).indexOf(rdn.toLowerCase(), offset1)) != -1) {

        if (offset1 > 0 && principal.charAt(offset1 - 1) != ',' && principal.charAt(offset1 - 1) != ' ') {
            offset1++;
            continue;
        }

        offset1 += rdn.length();
        while (offset1 < principal.length() && principal.charAt(offset1) == ' ') {
            offset1++;
        }

        if (offset1 >= principal.length()) {
            return null;
        }

        if (principal.charAt(offset1) != '=') {
            continue;
        }

        offset1++;
        while (offset1 < principal.length() && principal.charAt(offset1) == ' ') {
            offset1++;
        }

        if (offset1 >= principal.length()) {
            return ""; //$NON-NLS-1$
        }

        int offset2;
        if (principal.charAt(offset1) == ',') {
            return ""; //$NON-NLS-1$
        } else if (principal.charAt(offset1) == '"') {
            offset1++;
            if (offset1 >= principal.length()) {
                return ""; //$NON-NLS-1$
            }

            offset2 = principal.indexOf('"', offset1);
            if (offset2 == offset1) {
                return ""; //$NON-NLS-1$
            } else if (offset2 != -1) {
                return principal.substring(offset1, offset2);
            } else {
                return principal.substring(offset1);
            }
        } else {
            offset2 = principal.indexOf(',', offset1);
            if (offset2 != -1) {
                return principal.substring(offset1, offset2).trim();
            }
            return principal.substring(offset1).trim();
        }
    }

    return null;
}

From source file:org.cloudfoundry.identity.uaa.web.ForwardAwareInternalResourceViewResolverTests.java

@Test
public void testResolveForwardWithAccept() throws Exception {
    request.addHeader("Accept", "application/json");
    resolver.setApplicationContext(new GenericApplicationContext());
    View view = resolver.resolveViewName("forward:foo", Locale.US);
    assertNotNull(view);//  www. ja  va2s . com
}

From source file:at.uni_salzburg.cs.ckgroup.cscpp.engine.actions.Picture.java

@Override
public String toString() {
    if (isComplete()) {
        return String.format(Locale.US, "Picture (%d, \"%s\")", getTimestamp(), getFilename());
    }/*from w ww.jav  a  2s . com*/
    return "Picture";
}

From source file:jp.classmethod.aws.brian.utils.GsonFactoryBean.java

@Override
public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
    sdf.setTimeZone(TimeZone.getTimeZone("Universal"));
    return new JsonPrimitive(sdf.format(src));
}

From source file:com.salesmanager.core.module.impl.application.currencies.USDCurrencyModule.java

public BigDecimal getAmount(String amount) throws Exception {

    if (!amount.contains(",") && !amount.contains(".") && !amount.contains(" ")) {

        if (CurrencyModuleUtil.matchPositiveInteger(amount)) {
            BigDecimalValidator validator = CurrencyValidator.getInstance();
            BigDecimal bdamount = validator.validate(amount, Locale.US);
            if (bdamount == null) {
                throw new ValidationException("Cannot parse " + amount);
            } else {
                return bdamount;
            }/*w  w  w. jav  a  2 s  . co  m*/
        } else {
            throw new ValidationException("Cannot parse " + amount);
        }

    } else {

        Matcher matcher = pattern.matcher(amount);

        if (matcher.matches()) {
            BigDecimalValidator validator = CurrencyValidator.getInstance();
            BigDecimal bdamount = validator.validate(amount, Locale.US);

            return bdamount;
        } else {
            throw new ValidationException("Cannot parse " + amount);
        }
    }
}

From source file:com.opencredo.portlet.BooksController.java

@InitBinder
protected void initBinder(PortletRequestDataBinder binder) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy", Locale.US);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
    binder.setAllowedFields(//  w ww .j  a  va2s  .  c  om
            new String[] { "author", "title", "description", "availability", "count", "website", "coverPng" });
}

From source file:org.whispercomm.c2dm4j.impl.C2dmHttpResponseHandlerTest.java

private HttpResponse buildResponse(int statusCode) {
    return new BasicHttpResponse(HttpVersion.HTTP_1_1, statusCode,
            EnglishReasonPhraseCatalog.INSTANCE.getReason(statusCode, Locale.US));
}

From source file:org.atomserver.core.dbstore.dao.ContentDAOTest.java

public void testDeleteAll1() throws Exception {
    EntryDescriptor entry = new BaseEntryDescriptor("widgets", "acme", "16661", Locale.US);
    EntryMetaData entryMetaData = insertContent(entry);
    contentDAO.deleteAllContent("widgets", "acme");

    assertFalse(contentDAO.contentExists(entryMetaData));
    assertEquals(null, contentDAO.selectContent(entryMetaData));

    entriesDAO.obliterateEntry(entry);//from www . j a  va 2 s .  c o  m
}

From source file:com.datastax.example.MapSizeTest.java

public void test1() {

    final CsvReporter reporter = CsvReporter.forRegistry(metrics).formatFor(Locale.US)
            .convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS)
            .build(new File("/Users/patrick/projects/"));

    logger.info("Beginning MapSizeTest:Test1");

    int key = 0;//from  w ww  .ja va2  s  .c o m

    reporter.start(1, TimeUnit.SECONDS);

    //Insert 100 items at a time, up to 64k items
    for (int i = 0; i < 640; i++) {

        for (int j = 0; j < 100; j++) {

            final Timer.Context context = requestLatency.time();
            session.execute("update maptest set intMap = {" + key + ":" + key + "} where id = 0");
            context.stop();

            key++;
        }
    }

    logger.info("Completed MapSizeTest:Test1");
}

From source file:org.freshrss.easyrss.network.NetworkClient.java

private HttpURLConnection makeConnection(final String url) throws MalformedURLException, IOException {
    final HttpURLConnection httpURLConnection = (HttpURLConnection) (new URL(url).openConnection());
    httpURLConnection.setConnectTimeout(40 * 1000);
    httpURLConnection.setReadTimeout(30 * 1000);
    if (url.toLowerCase(Locale.US).startsWith("https://")) {
        final HttpsURLConnection httpsURLConnection = (HttpsURLConnection) httpURLConnection;
        httpsURLConnection.setSSLSocketFactory(this.sslSocketFactory);
    }// w  w  w  . j  a  v  a  2  s.c  o m
    return httpURLConnection;
}