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:at.uni_salzburg.cs.ckgroup.cscpp.viewer.json.VirtualVehicleQuery.java

@Override
public String execute(IServletConfig config, String[] parameters) {

    if (mapperProxy.getEngineInfoList() == null) {
        return "";
    }/*ww w  . ja v  a  2  s .c om*/

    // TODO do this in parallel
    Map<String, Object> vehicleStatus = new LinkedHashMap<String, Object>();

    int pilotNumber = 0;
    for (EngineInfo engineInfo : mapperProxy.getEngineInfoList()) {
        String vehicleStatusString = null;
        String pilot = String.format(Locale.US, "pilot%03d", ++pilotNumber);
        try {
            String pilotName = engineInfo.getPilotName();
            String vehicleStatusURL = engineInfo.getVehicleStatusUrl();
            if (pilotName != null && vehicleStatusURL != null) {
                vehicleStatusString = HttpQueryUtils.simpleQuery(vehicleStatusURL);
                Map<String, Object> p = new LinkedHashMap<String, Object>();
                p.put("name", pilotName);
                p.put("engine", engineInfo.getActionPointUrl());
                p.put("vehicleData", engineInfo.getVehicleDataUrl());
                p.put("vehicles", parser.parse(vehicleStatusString));
                vehicleStatus.put(pilot, p);
            }
        } catch (Exception e) {
            LOG.info("Can not query pilot " + pilot + ": " + vehicleStatusString, e);
        }
    }

    return JSONValue.toJSONString(vehicleStatus);
}

From source file:com.erudika.para.i18n.CurrencyUtils.java

private CurrencyUtils() {
    Locale[] locales = Locale.getAvailableLocales();
    try {/* w w  w  . j a v  a 2 s .c  o m*/
        for (Locale l : locales) {
            if (!StringUtils.isBlank(l.getCountry())) {
                COUNTRY_TO_LOCALE_MAP.put(l.getCountry(), l);
                Currency c = Currency.getInstance(l);
                if (c != null) {
                    CURRENCY_TO_LOCALE_MAP.put(c.getCurrencyCode(), l);
                    CURRENCIES_MAP.put(c.getCurrencyCode(),
                            getCurrencyName(c.getCurrencyCode(), Locale.US).concat(" ").concat(c.getSymbol(l)));
                }
            }
        }
        // overwrite main locales
        CURRENCY_TO_LOCALE_MAP.put("USD", Locale.US);
        CURRENCY_TO_LOCALE_MAP.put("EUR", Locale.FRANCE);
    } catch (Exception e) {
        logger.error(null, e);
    }
}

From source file:de.cubeisland.engine.core.module.ModuleInfo.java

private static String nameToId(String name) {
    name = name.toLowerCase(Locale.US);
    name = name.replaceAll("[^a-z0-9]", "");
    return name;//from w  w w . java  2s  . c o m
}

From source file:com.github.jmnarloch.spring.cloud.feign.app.resource.InvoiceResource.java

private List<Invoice> createInvoiceList(int count) {
    final List<Invoice> invoices = new ArrayList<>();
    for (int ind = 0; ind < count; ind++) {
        final Invoice invoice = new Invoice();
        invoice.setTitle("Invoice " + (ind + 1));
        invoice.setAmount(new BigDecimal(String.format(Locale.US, "%.2f", Math.random() * 1000)));
        invoices.add(invoice);/*from  w  w w .j  a v a 2  s  .co  m*/
    }
    return invoices;
}

From source file:com.ratebeer.android.api.command.GetUserTicksCommand.java

@Override
protected void parse(JSONArray json) throws JSONException {
    SimpleDateFormat dateFormat = new SimpleDateFormat("M/d/yyyy h:mm:ss a", Locale.US);
    userTicks = new ArrayList<UserTick>();
    for (int i = 0; i < json.length(); i++) {
        JSONObject result = json.getJSONObject(i);
        String entered = result.getString("TimeEntered");
        Date timeEntered = null;//from   w  ww  .j  ava  2  s  .  co m
        try {
            timeEntered = dateFormat.parse(entered);
        } catch (ParseException e) {
        }
        userTicks.add(new UserTick(result.getInt("BeerID"), result.getInt("Liked"), timeEntered));
    }

}

From source file:com.github.horrorho.inflatabledonkey.requests.MappedHeaders.java

@Override
public Header get(String header) throws NullPointerException {
    if (headers.containsKey(header.toLowerCase(Locale.US))) {
        return headers.get(header.toLowerCase(Locale.US));
    }//from  w w w.  ja  v a2  s  .  c  o m

    throw new NullPointerException("Missing header: " + header);
}

From source file:com.kii.sdk.photocolle.http.entity.mime.Header.java

public void addField(final MinimalField field) {
    if (field == null) {
        return;//w w w  . j a  va 2 s. c om
    }
    String key = field.getName().toLowerCase(Locale.US);
    List<MinimalField> values = this.fieldMap.get(key);
    if (values == null) {
        values = new LinkedList<MinimalField>();
        this.fieldMap.put(key, values);
    }
    values.add(field);
    this.fields.add(field);
}

From source file:dk.laundav.locationservice.service.ReverseGeocoder.java

private static String addLocationToUrl(AbstractLocationObject location) {

    String latitude = String.format(Locale.US, "%.10f", location.getLatitude());
    String longitude = String.format(Locale.US, "%.10f", location.getLongitude());

    String url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + longitude + "," + latitude
            + "&sensor=true";

    System.out.println(url);//from   ww  w  .  j  ava  2  s  .c  om

    return url;

}

From source file:be.wegenenverkeer.common.resteasy.json.Iso8601AndOthersDateFormat.java

@Override
public Date parse(String str, ParsePosition pos) {
    Date date = null;//  w  ww  . j  ava2  s.  c o  m

    if (!StringUtils.isBlank(str)) {
        // try ISO 8601 format first
        try {
            return iso8601NozoneFormat.parse(str, pos);
        } catch (IllegalArgumentException iae) {
            // ignore, try next format
            date = null; // dummy
        }

        // then try a list of formats
        for (String format : FORMATS) {
            DateFormat formatter = new SimpleDateFormat(format, Locale.US);
            try {
                return formatter.parse(str);
            } catch (ParseException e) {
                // ignore, try next format
                date = null; // dummy
            }
        }
        throw new IllegalArgumentException("Could not parse date " + str
                + " using ISO 8601 or any of the formats " + Arrays.asList(FORMATS) + ".");

    }
    return date; // empty string

}

From source file:com.ibk.ltw.domain.Product.java

public String getNetPriceAsText() {
    BigDecimal netPriceInDollars = new BigDecimal(getNetPriceInCents()).movePointLeft(2);
    return NumberFormat.getCurrencyInstance(Locale.US).format(netPriceInDollars);
}