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:com.switchfly.inputvalidation.sanitizer.LocaleCodeSanitizer.java

private String getDefaultLocale(String content) {
    String sanitized = new HtmlSanitizer().execute(content);
    _logger.warn("Invalid locale code (" + sanitized + "). Setting locale code to \"en_US\".");
    return Locale.US.toString();
}

From source file:com.mercandalli.android.apps.files.user.UserConversationMessageModel.java

public UserConversationMessageModel(final Activity activity, final JSONObject json) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.US);
    try {/*  w w  w. j  a  va  2  s.c  om*/
        if (json.has("id")) {
            this.id = json.getInt("id");
        }
        if (json.has("id_conversation")) {
            this.id_conversation = json.getInt("id_conversation");
        }
        if (json.has("id_user")) {
            this.id_user = json.getInt("id_user");
        }
        if (json.has("content")) {
            this.content = json.getString("content");
        }
        if (json.has("user")) {
            this.user = new UserModel(json.getJSONObject("user"));
        }
        if (json.has("date_creation") && !json.isNull("date_creation")) {
            this.date_creation = dateFormat.parse(json.getString("date_creation"));
        }
    } catch (JSONException | ParseException e) {
        Log.e(getClass().getName(), "Failed to convert Json", e);
    }
}

From source file:com.inovaworks.ObservedProperty.java

public static ObservedProperty verticalSpeed(double speedMps) {
    return new ObservedProperty("verticalSpeed", String.format(Locale.US, "%.2f", speedMps * 3.6), "km/h");
}

From source file:kontrol.HttpUtil.java

public static InputStream getUrlAsStream(URL url, int timeout) throws IOException {
    return getUrlAsStream(URI.create(url.toString()), timeout, Locale.US);
}

From source file:com.ok2c.lightmtp.impl.protocol.cmd.DefaultProtocolHandler.java

public void register(final String cmd, final CommandHandler<ServerState> handler) {
    Args.notNull(cmd, "Command name");
    Args.notNull(handler, "Command handler");
    this.map.put(cmd.toUpperCase(Locale.US), handler);
}

From source file:com.frostwire.search.academictorrents.AcademicTorrentsCrawledSearchResult.java

public AcademicTorrentsCrawledSearchResult(AcademicTorrentsSearchResult sr, AcademicTorrentsFile file) {
    super(sr);/*from  w w w . j  a  v  a2  s .  co  m*/
    this.filename = file.filename;
    this.displayName = FilenameUtils.getBaseName(filename) + " (" + sr.getDisplayName() + ")";
    this.downloadUrl = String.format(Locale.US, DOWNLOAD_URL, sr.getDomainName(), sr.getIdentifier(), filename);
    this.size = calcSize(file);
}

From source file:com.appsimobile.appsii.module.weather.loader.WeatherDataParser.java

public static void parseWeatherData(CircularArray<WeatherData> result, String jsonString,
        CircularArray<String> woeids) throws JSONException, ResponseParserException, ParseException {

    if (woeids.isEmpty())
        return;//from ww  w  .  j  a v a 2 s .  c  om

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy", Locale.US);
    simpleDateFormat.setTimeZone(TimeZone.getTimeZone(Time.TIMEZONE_UTC));

    SimpleJson json = new SimpleJson(jsonString);

    // when only a single woeid was requested, this is an object, otherwise it is an array.
    // So we need to check if we got an array; if so, handle each of the objects.
    // Otherwise get it as an object
    JSONArray resultsArray = json.getJsonArray("query.results.channel");

    if (resultsArray == null) {
        JSONObject weatherObject = json.optJsonObject("query.results.channel");
        if (weatherObject == null)
            return;

        String woeid = woeids.get(0);
        WeatherData weatherData = parseWeatherData(woeid, simpleDateFormat, weatherObject);
        if (weatherData != null) {
            result.addLast(weatherData);
        }
        return;
    }

    int length = resultsArray.length();
    for (int i = 0; i < length; i++) {
        JSONObject weatherJson = resultsArray.getJSONObject(i);
        WeatherData weatherData = parseWeatherData(woeids.get(i), simpleDateFormat, weatherJson);
        if (weatherData == null)
            continue;

        result.addLast(weatherData);

    }
}

From source file:com.android.volley.VolleyLog.java

/**
 * Formats the caller's provided message and prepends useful info like
 * calling thread ID and method name./*from   w ww . j  a  v a  2 s .  c om*/
 */
private static String buildMessage(String format, Object... args) {
    String msg = (args == null) ? format : String.format(Locale.US, format, args);
    StackTraceElement[] trace = new Throwable().fillInStackTrace().getStackTrace();

    String caller = "<unknown>";
    // Walk up the stack looking for the first caller outside of VolleyLog.
    // It will be at least two frames up, so start there.
    for (int i = 2; i < trace.length; i++) {
        Class<?> clazz = trace[i].getClass();
        if (!clazz.equals(VolleyLog.class)) {
            String callingClass = trace[i].getClassName();
            callingClass = callingClass.substring(callingClass.lastIndexOf('.') + 1);
            callingClass = callingClass.substring(callingClass.lastIndexOf('$') + 1);

            caller = callingClass + "." + trace[i].getMethodName();
            break;
        }
    }
    return String.format(Locale.US, "[%d] %s: %s", Thread.currentThread().getId(), caller, msg);
}

From source file:com.aestheticsw.jobkeywords.service.termextractor.impl.indeed.IndeedClientTest.java

@Test
public void getIndeedJobDetails() {
    QueryKey key = new QueryKey("java spring", Locale.US, null);
    SearchParameters params = new SearchParameters(key, 10, 0, 0, null);
    List<JobSummary> jobSummaryList = indeedClient.getIndeedJobSummaryList(params);
    assertNotNull(jobSummaryList);// w w w . j  av  a 2s  .  c o m
    //        assertEquals(1, jobSummaryList.size());
    JobSummary jobSummary = jobSummaryList.get(2);
    String jobDetailsUrl = jobSummary.getUrl();
    assertNotNull(jobDetailsUrl);

    String details = indeedClient.getIndeedJobDetails(jobDetailsUrl);
    assertNotNull(details);
    assertTrue(StringUtils.isNotEmpty(details));
}

From source file:org.apache.juneau.rest.test.TestMicroservice.java

/**
 * Starts the microservice./*from ww  w. j a v a 2  s . c o  m*/
 * @return <jk>true</jk> if the service started, <jk>false</jk> if it's already started.
 * If this returns <jk>false</jk> then don't call stopMicroservice()!.
 */
public static boolean startMicroservice() {
    if (microservice != null)
        return false;
    try {
        Locale.setDefault(Locale.US);
        microservice = new RestMicroservice().setConfig("juneau-rest-test.cfg", false)
                .setManifestContents("Test-Entry: test-value");
        microserviceURI = microservice.start().getURI();
        DEFAULT_CLIENT = client().build();
        DEFAULT_CLIENT_PLAINTEXT = client(PlainTextSerializer.class, PlainTextParser.class).build();
        return true;
    } catch (Throwable e) {
        System.err.println(e); // NOT DEBUG
        return false;
    }
}