Example usage for java.text DecimalFormatSymbols DecimalFormatSymbols

List of usage examples for java.text DecimalFormatSymbols DecimalFormatSymbols

Introduction

In this page you can find the example usage for java.text DecimalFormatSymbols DecimalFormatSymbols.

Prototype

public DecimalFormatSymbols() 

Source Link

Document

Create a DecimalFormatSymbols object for the default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:org.geomajas.layer.wms.WmsLayer.java

/**
 * Build the base part of the url (doesn't change for getMap or getFeatureInfo requests).
 * /*from   w ww  . j a  v  a  2 s  .  c  om*/
 * @param targetUrl
 *            base url
 * @param width
 *            image width
 * @param height
 *            image height
 * @param box
 *            bounding box
 * @return base WMS url
 * @throws GeomajasException
 *             missing parameter
 */
private StringBuilder formatBaseUrl(String targetUrl, int width, int height, Bbox box)
        throws GeomajasException {
    try {
        StringBuilder url = new StringBuilder(targetUrl);
        int pos = url.lastIndexOf("?");
        if (pos > 0) {
            url.append("&SERVICE=WMS");
        } else {
            url.append("?SERVICE=WMS");
        }
        String layers = getId();
        if (layerInfo.getDataSourceName() != null) {
            layers = layerInfo.getDataSourceName();
        }
        url.append("&layers=");
        url.append(URLEncoder.encode(layers, "UTF8"));
        url.append("&WIDTH=");
        url.append(Integer.toString(width));
        url.append("&HEIGHT=");
        url.append(Integer.toString(height));
        DecimalFormat decimalFormat = new DecimalFormat(); // create new as this is not thread safe
        decimalFormat.setDecimalSeparatorAlwaysShown(false);
        decimalFormat.setGroupingUsed(false);
        decimalFormat.setMinimumFractionDigits(0);
        decimalFormat.setMaximumFractionDigits(100);
        DecimalFormatSymbols symbols = new DecimalFormatSymbols();
        symbols.setDecimalSeparator('.');
        decimalFormat.setDecimalFormatSymbols(symbols);

        url.append("&bbox=");
        url.append(decimalFormat.format(box.getX()));
        url.append(",");
        url.append(decimalFormat.format(box.getY()));
        url.append(",");
        url.append(decimalFormat.format(box.getMaxX()));
        url.append(",");
        url.append(decimalFormat.format(box.getMaxY()));
        url.append("&format=");
        url.append(format);
        url.append("&version=");
        url.append(version);
        if ("1.3.0".equals(version)) {
            url.append("&crs=");
        } else {
            url.append("&srs=");
        }
        url.append(URLEncoder.encode(layerInfo.getCrs(), "UTF8"));
        url.append("&styles=");
        url.append(styles);
        if (null != parameters) {
            for (Parameter p : parameters) {
                url.append("&");
                url.append(URLEncoder.encode(p.getName(), "UTF8"));
                url.append("=");
                url.append(URLEncoder.encode(p.getValue(), "UTF8"));
            }
        }
        if (useProxy && null != securityContext.getToken()) {
            url.append("&userToken=");
            url.append(securityContext.getToken());
        }
        return url;
    } catch (UnsupportedEncodingException uee) {
        throw new IllegalStateException("Cannot find UTF8 encoding?", uee);
    }
}

From source file:LPGoogleFunctions.LPGoogleFunctions.java

/**
 * The Google Maps Image APIs make it easy to embed a street view image into your image view.
 * @param address - The address (such as Chagrin Falls, OH).
 * @param imageWidth - Specifies width size of the image in pixels.
 * @param imageHeight - Specifies height size of the image in pixels.
 * @param heading - Indicates the compass heading of the camera. Accepted values are from 0 to 360 (both values indicating North, with 90 indicating East, and 180 South). 
 * If no heading is specified, a value will be calculated that directs the camera towards the specified location, from the point at which the closest photograph was taken.
 * @param fov - Determines the horizontal field of view of the image. The field of view is expressed in degrees, with a maximum allowed value of 120.
 * When dealing with a fixed-size viewport, as with a Street View image of a set size, field of view in essence represents zoom, with smaller numbers indicating a higher level of zoom.
 * @param pitch- Specifies the up or down angle of the camera relative to the Street View vehicle. This is often, but not always, flat horizontal.
 * Positive values angle the camera up (with 90 degrees indicating straight up).
 * Negative values angle the camera down (with -90 indicating straight down).
 * @param responseHandler/*from   www .j a v a2  s  .c  o m*/
 * @Override public void willLoadStreetViewImage();
 * @Override public void didLoadStreetViewImage(Bitmap bmp)
 * @Override public void errorLoadingStreetViewImage(Throwable error);
 */

public void loadStreetViewImageForAddress(String address, int imageWidth, int imageHeight, float heading,
        float fov, float pitch, final StreetViewImageListener responseHandler) {
    if (responseHandler != null)
        responseHandler.willLoadStreetViewImage();

    RequestParams parameters = new RequestParams();

    DecimalFormatSymbols separator = new DecimalFormatSymbols();
    separator.setDecimalSeparator('.');
    DecimalFormat coordinateDecimalFormat = new DecimalFormat("##.######");
    coordinateDecimalFormat.setDecimalFormatSymbols(separator);

    DecimalFormat twoDecimalFormat = new DecimalFormat(".##");
    twoDecimalFormat.setDecimalFormatSymbols(separator);

    parameters.put("key", this.googleAPIBrowserKey);
    parameters.put("sensor", sensor ? "true" : "false");
    parameters.put("size", String.format("%dx%d", imageWidth, imageHeight));
    if (address != null)
        parameters.put("location", address);
    parameters.put("heading", twoDecimalFormat.format(heading));
    parameters.put("fov", twoDecimalFormat.format(fov));
    parameters.put("pitch", twoDecimalFormat.format(pitch));

    this.client.get(googleAPIStreetViewImageURL, parameters, new BinaryHttpResponseHandler() {
        @Override
        public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
            if (responseHandler != null)
                responseHandler.errorLoadingStreetViewImage(arg3);
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
            try {
                Bitmap bmp = BitmapFactory.decodeByteArray(arg2, 0, arg2.length);

                if (responseHandler != null)
                    responseHandler.didLoadStreetViewImage(bmp);
            } catch (Exception e) {
                e.printStackTrace();

                if (responseHandler != null)
                    responseHandler.errorLoadingStreetViewImage(e.getCause());
            }
        }
    });
}

From source file:LPGoogleFunctions.LPGoogleFunctions.java

/**
 * The Google Maps Image APIs make it easy to embed a static Google Maps image into your image view.
 * @param location - The location (such as 40.457375,-80.009353).
 * @param zoomLevel - (required if markers not present) defines the zoom level of the map, which determines the magnification level of the map.
 * This parameter takes a numerical value corresponding to the zoom level of the region desired.
 * @param imageWidth - Specifies width size of the image in pixels.
 * @param imageHeight - Specifies height size of the image in pixels.
 * @param imageScale - (optional) affects the number of pixels that are returned. scale=2 returns twice as many pixels as scale=1 while retaining the same coverage area and level of detail (i.e. the contents of the map don't change).
 * This is useful when developing for high-resolution displays, or when generating a map for printing. The default value is 1.
 * @param mapType - (optional) defines the type of map to construct. There are several possible maptype values, including roadmap, satellite, hybrid, and terrain. Use LPGoogleMapType.
 * @param markers - (optional) define one or more markers to attach to the image at specified locations. This parameter takes a single marker definition with parameters separated by the pipe character (|).
 * Multiple markers may be placed within the same markers parameter as long as they exhibit the same style; you may add additional markers of differing styles by adding additional markers parameters.
 * Note that if you supply markers for a map, you do not need to specify the (normally required) center and zoom parameters. Use LPMapImageMarker.
 * @param responseHandler/*www  .j a  v  a  2 s. com*/
 * @Override public void willLoadStaticMapImage()
 * @Override public void didLoadStaticMapImage(Bitmap bmp)
 * @Override public void errorLoadingStaticMapImage(Throwable error)
 */

public void loadStaticMapImageForLocation(LPLocation location, int zoomLevel, int imageWidth, int imageHeight,
        int imageScale, LPGoogleMapType mapType, ArrayList<LPMapImageMarker> markers,
        final StaticMapImageListener responseHandler) {
    if (responseHandler != null)
        responseHandler.willLoadStaticMapImage();

    StringBuilder URL = new StringBuilder(googleAPIStaticMapImageURL);

    DecimalFormatSymbols separator = new DecimalFormatSymbols();
    separator.setDecimalSeparator('.');
    DecimalFormat coordinateDecimalFormat = new DecimalFormat("##.######");
    coordinateDecimalFormat.setDecimalFormatSymbols(separator);

    if (location != null)
        URL.append(String.format("center=%s,%s&", coordinateDecimalFormat.format(location.latitude),
                coordinateDecimalFormat.format(location.longitude)));
    URL.append(String.format("sensor=%s&", this.sensor ? "true" : "false"));
    URL.append(String.format("zoom=%d&", zoomLevel));
    URL.append(String.format("scale=%d&", imageScale));
    URL.append(String.format("size=%dx%d&", imageWidth, imageHeight));
    URL.append(String.format("maptype=%s&", LPGoogleFunctions.getMapType(mapType)));

    if (markers != null) {
        for (int i = 0; i < markers.size(); i++) {
            LPMapImageMarker marker = markers.get(i);

            URL.append(String.format("markers=%s&", marker.getMarkerURLString()));
        }
    }

    this.client.get(URL.toString(), new BinaryHttpResponseHandler() {
        @Override
        public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
            if (responseHandler != null)
                responseHandler.errorLoadingStaticMapImage(arg3);
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
            try {
                Bitmap bmp = BitmapFactory.decodeByteArray(arg2, 0, arg2.length);

                if (responseHandler != null)
                    responseHandler.didLoadStaticMapImage(bmp);
            } catch (Exception e) {
                e.printStackTrace();

                if (responseHandler != null)
                    responseHandler.errorLoadingStaticMapImage(e.getCause());
            }
        }
    });
}

From source file:LPGoogleFunctions.LPGoogleFunctions.java

/**
 * The Google Maps Image APIs make it easy to embed a static Google Maps image into your image view.
 * @param address - The address (such as Chagrin Falls, OH).
 * @param zoomLevel - (required if markers not present) defines the zoom level of the map, which determines the magnification level of the map.
 * This parameter takes a numerical value corresponding to the zoom level of the region desired.
 * @param imageWidth - Specifies width size of the image in pixels.
 * @param imageHeight - Specifies height size of the image in pixels.
 * @param imageScale - (optional) affects the number of pixels that are returned. scale=2 returns twice as many pixels as scale=1 while retaining the same coverage area and level of detail (i.e. the contents of the map don't change).
 * This is useful when developing for high-resolution displays, or when generating a map for printing. The default value is 1.
 * @param mapType - (optional) defines the type of map to construct. There are several possible maptype values, including roadmap, satellite, hybrid, and terrain. Use LPGoogleMapType.
 * @param markers - (optional) define one or more markers to attach to the image at specified locations. This parameter takes a single marker definition with parameters separated by the pipe character (|).
 * Multiple markers may be placed within the same markers parameter as long as they exhibit the same style; you may add additional markers of differing styles by adding additional markers parameters.
 * Note that if you supply markers for a map, you do not need to specify the (normally required) center and zoom parameters. Use LPMapImageMarker.
 * @param responseHandler//from   w ww .  j  a  v  a2s  .c om
 * @Override public void willLoadStaticMapImage()
 * @Override public void didLoadStaticMapImage(Bitmap bmp)
 * @Override public void errorLoadingStaticMapImage(Throwable error)
 */

public void loadStaticMapImageForAddress(String address, int zoomLevel, int imageWidth, int imageHeight,
        int imageScale, LPGoogleMapType mapType, ArrayList<LPMapImageMarker> markers,
        final StaticMapImageListener responseHandler) {
    if (responseHandler != null)
        responseHandler.willLoadStaticMapImage();

    StringBuilder URL = new StringBuilder(googleAPIStaticMapImageURL);

    DecimalFormatSymbols separator = new DecimalFormatSymbols();
    separator.setDecimalSeparator('.');
    DecimalFormat coordinateDecimalFormat = new DecimalFormat("##.######");
    coordinateDecimalFormat.setDecimalFormatSymbols(separator);

    if (address != null)
        URL.append(String.format("center=%s&", address));
    URL.append(String.format("sensor=%s&", this.sensor ? "true" : "false"));
    URL.append(String.format("zoom=%d&", zoomLevel));
    URL.append(String.format("scale=%d&", imageScale));
    URL.append(String.format("size=%dx%d&", imageWidth, imageHeight));
    URL.append(String.format("maptype=%s&", LPGoogleFunctions.getMapType(mapType)));

    if (markers != null) {
        for (int i = 0; i < markers.size(); i++) {
            LPMapImageMarker marker = markers.get(i);

            URL.append(String.format("markers=%s&", marker.getMarkerURLString()));
        }
    }

    this.client.get(URL.toString(), new BinaryHttpResponseHandler() {
        @Override
        public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
            if (responseHandler != null)
                responseHandler.errorLoadingStaticMapImage(arg3);
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
            try {
                Bitmap bmp = BitmapFactory.decodeByteArray(arg2, 0, arg2.length);

                if (responseHandler != null)
                    responseHandler.didLoadStaticMapImage(bmp);
            } catch (Exception e) {
                e.printStackTrace();

                if (responseHandler != null)
                    responseHandler.errorLoadingStaticMapImage(e.getCause());
            }
        }
    });
}

From source file:LPGoogleFunctions.LPGoogleFunctions.java

/**
 * The Google Places Autocomplete API is a web service that returns Place information based on text search terms, and, optionally, geographic bounds.
 * The API can be used to provide autocomplete functionality for text-based geographic searches, by returning Places such as businesses, addresses, and points of interest as a user types.
 * @param input - The text string on which to search. The Place service will return candidate matches based on this string and order results based on their perceived relevance.
 * @param offset - The character position in the input term at which the service uses text for predictions. For example, if the input is 'Googl' and the completion point is 3, the service will match on 'Goo'. The offset should generally be set to the position of the text caret. If no offset is supplied, the service will use the entire term.
 * @param radius - The distance (in meters) within which to return Place results. Note that setting a radius biases results to the indicated area, but may not fully restrict results to the specified area.
 * @param location - The point around which you wish to retrieve Place information. Must be specified as latitude,longitude.
 * @param placeType - The types of Place results to return. If no type is specified, all types will be returned. See LPPrediction.h for types.
 * @param countryRestriction - The country must be passed as a two character.
 * @param responseHandler/*from  w  w  w  .ja v  a2s.  co m*/
 * @Override public void willLoadPlacesAutocomplete()
 * @Override public void didLoadPlacesAutocomplete(LPPlacesAutocomplete placesAutocomplete)
 * @Override public void errorLoadingPlacesAutocomplete(LPGoogleStatus status)
 */

public void loadPlacesAutocompleteForInput(String input, int offset, int radius, LPLocation location,
        LPGooglePlaceType placeType, String countryRestriction,
        final PlacesAutocompleteListener responseHandler) {
    if (responseHandler != null)
        responseHandler.willLoadPlacesAutocomplete();

    RequestParams parameters = new RequestParams();

    DecimalFormatSymbols separator = new DecimalFormatSymbols();
    separator.setDecimalSeparator('.');
    DecimalFormat coordinateDecimalFormat = new DecimalFormat("##.######");
    coordinateDecimalFormat.setDecimalFormatSymbols(separator);

    parameters.put("key", this.googleAPIBrowserKey);
    if (input != null)
        parameters.put("input", input);
    parameters.put("types", LPPrediction.getStringFromGooglePlaceType(placeType));
    parameters.put("offset", String.format("%d", offset));
    parameters.put("radius", String.format("%d", radius));
    if (location != null)
        parameters.put("location", String.format("%s,%s", coordinateDecimalFormat.format(location.latitude),
                coordinateDecimalFormat.format(location.longitude)));
    parameters.put("sensor", this.sensor ? "true" : "false");
    parameters.put("language", this.languageCode);

    if (countryRestriction != null) {
        parameters.put("components", String.format("country:%s", countryRestriction));
    }

    this.client.get(googleAPIPlacesAutocompleteURL, parameters, new AsyncHttpResponseHandler() {
        @Override
        public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
            if (responseHandler != null)
                responseHandler.errorLoadingPlacesAutocomplete(LPGoogleStatus.LPGoogleStatusUnknownError);
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
            try {
                String response = new String(arg2, "UTF-8");

                JSONObject object = new JSONObject(response);

                LPPlacesAutocomplete placesAutocomplete = new LPPlacesAutocomplete(object);

                LPGoogleStatus status = LPGoogleFunctions
                        .getGoogleStatusFromString(placesAutocomplete.statusCode);

                if (status == LPGoogleStatus.LPGoogleStatusOK) {
                    if (responseHandler != null)
                        responseHandler.didLoadPlacesAutocomplete(placesAutocomplete);
                } else {
                    if (responseHandler != null)
                        responseHandler.errorLoadingPlacesAutocomplete(status);
                }
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();

                if (responseHandler != null)
                    responseHandler.errorLoadingPlacesAutocomplete(LPGoogleStatus.LPGoogleStatusUnknownError);
            } catch (JSONException e) {
                e.printStackTrace();

                if (responseHandler != null)
                    responseHandler.errorLoadingPlacesAutocomplete(LPGoogleStatus.LPGoogleStatusUnknownError);
            }
        }
    });
}

From source file:org.openbravo.advpaymentmngt.utility.FIN_Utility.java

/**
 * Convert a multi currency amount to a string for display in the UI. If amount has been converted
 * to a different currency, then output that converted amount and currency as well
 * /*from  ww  w .j av a  2 s  .  c  om*/
 * @param amt
 *          Amount of payment
 * @param currency
 *          Currency payment was made in
 * @param convertedAmt
 *          Amount of payment in converted currency
 * @param convertedCurrency
 *          Currency payment was converted to/from
 * @return String version of amount formatted for display to user
 */
public static String multiCurrencyAmountToDisplay(BigDecimal amt, Currency currency, BigDecimal convertedAmt,
        Currency convertedCurrency) {
    StringBuffer out = new StringBuffer();
    final UIDefinitionController.FormatDefinition formatDef = UIDefinitionController.getInstance()
            .getFormatDefinition("euro", "Edition");

    String formatWithDot = formatDef.getFormat();
    DecimalFormatSymbols dfs = new DecimalFormatSymbols();
    try {
        dfs.setDecimalSeparator(formatDef.getDecimalSymbol().charAt(0));
        dfs.setGroupingSeparator(formatDef.getGroupingSymbol().charAt(0));
        // Use . as decimal separator
        final String DOT = ".";
        if (!DOT.equals(formatDef.getDecimalSymbol())) {
            formatWithDot = formatWithDot.replace(formatDef.getGroupingSymbol(), "@");
            formatWithDot = formatWithDot.replace(formatDef.getDecimalSymbol(), ".");
            formatWithDot = formatWithDot.replace("@", ",");
        }
    } catch (Exception e) {
        // If any error use euroEdition default format
        formatWithDot = "#0.00";
    }
    DecimalFormat amountFormatter = new DecimalFormat(formatWithDot, dfs);
    amountFormatter.setMaximumFractionDigits(currency.getStandardPrecision().intValue());

    out.append(amountFormatter.format(amt));
    if (convertedCurrency != null && !currency.equals(convertedCurrency)
            && amt.compareTo(BigDecimal.ZERO) != 0) {
        amountFormatter.setMaximumFractionDigits(convertedCurrency.getStandardPrecision().intValue());
        out.append(" (").append(amountFormatter.format(convertedAmt)).append(" ")
                .append(convertedCurrency.getISOCode()).append(")");
    }

    return out.toString();
}

From source file:thesis.Ontology_System.java

public String commaMaker(String price) {

    DecimalFormatSymbols symbols = new DecimalFormatSymbols();
    symbols.setGroupingSeparator(',');
    symbols.setDecimalSeparator('.');
    String pattern = "#,##0.0#";
    DecimalFormat df = new DecimalFormat(pattern, symbols);
    df.setParseBigDecimal(true);// ww  w  . j a v a  2 s  .  c  o  m

    /*price = proposed.replaceAll(Pattern.quote(","),"");
    equi = equi.replaceAll(Pattern.quote(","),"");
    other = other.replaceAll(Pattern.quote(","),"");
            
    if("".equals(proposed)){proposed = "0";}
    if("".equals(equi)){equi = "0";}
    if("".equals(other)){other = "0";}*/

    BigDecimal price_i = new BigDecimal(price);

    /*      BigDecimal equi_i = new BigDecimal(equi);
    BigDecimal other_i = new BigDecimal(other);
    BigDecimal total = new BigDecimal("0");
            
    total = total.add(proposed_i);
    total = total.add(equi_i);
    total = total.add(other_i);
    */
    return df.format(price_i);

}

From source file:LPGoogleFunctions.LPGoogleFunctions.java

/**
 * Geocoding is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain View, CA") into geographic coordinates 
 * (like latitude 37.423021 and longitude -122.083739), which you can use to place markers or position the map.
 * @param address - The location (such as 40.457375,-80.009353).
 * @param filterComponents - A component filter for which you wish to obtain a geocode.
 * The components filter will also be accepted as an optional parameter if an address is provided. See LPGeocodingFilter.h for components.
 * @param responseHandler/*from w w w . ja v  a  2  s . c  o  m*/
 * @Override public void willLoadGeocoding()
 * @Override public void didLoadGeocoding(LPGeocodingResults geocodingResults)
 * @Override public void errorLoadingGeocoding(LPGoogleStatus status)
 */

public void loadGeocodingForLocation(LPLocation location, ArrayList<LPGeocodingFilter> filterComponents,
        final GeocodingListener responseHandler) {
    if (responseHandler != null)
        responseHandler.willLoadGeocoding();

    RequestParams parameters = new RequestParams();

    DecimalFormatSymbols separator = new DecimalFormatSymbols();
    separator.setDecimalSeparator('.');
    DecimalFormat coordinateDecimalFormat = new DecimalFormat("##.######");
    coordinateDecimalFormat.setDecimalFormatSymbols(separator);

    if (location != null)
        parameters.put("latlng", String.format("%s,%s", coordinateDecimalFormat.format(location.latitude),
                coordinateDecimalFormat.format(location.longitude)));
    parameters.put("sensor", this.sensor ? "true" : "false");
    parameters.put("language", this.languageCode);

    //COMPONENTS FILTER
    if (filterComponents != null) {
        if (filterComponents.size() > 0) {
            StringBuilder comString = new StringBuilder("components=");

            for (int i = 0; i < filterComponents.size(); i++) {
                LPGeocodingFilter filter = filterComponents.get(i);

                comString.append(String.format("%s:%s", LPGeocodingFilter.getGeocodingFilter(filter.filter),
                        filter.value));
            }
        }
    }

    this.client.get(googleAPIGeocodingURL, parameters, new AsyncHttpResponseHandler() {
        @Override
        public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
            if (responseHandler != null)
                responseHandler.errorLoadingGeocoding(LPGoogleStatus.LPGoogleStatusUnknownError);
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
            try {
                String response = new String(arg2, "UTF-8");

                JSONObject object = new JSONObject(response);

                LPGeocodingResults geocodingResults = new LPGeocodingResults(object);

                LPGoogleStatus status = LPGoogleFunctions
                        .getGoogleStatusFromString(geocodingResults.statusCode);

                if (status == LPGoogleStatus.LPGoogleStatusOK) {
                    if (responseHandler != null)
                        responseHandler.didLoadGeocoding(geocodingResults);
                } else {
                    if (responseHandler != null)
                        responseHandler.errorLoadingGeocoding(status);
                }
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();

                if (responseHandler != null)
                    responseHandler.errorLoadingGeocoding(LPGoogleStatus.LPGoogleStatusUnknownError);
            } catch (JSONException e) {
                e.printStackTrace();

                if (responseHandler != null)
                    responseHandler.errorLoadingGeocoding(LPGoogleStatus.LPGoogleStatusUnknownError);
            }
        }
    });
}

From source file:org.openbravo.advpaymentmngt.utility.FIN_Utility.java

/**
 * Formats a number using the given format, decimal and grouping separator.
 * //from w w w . j  a  v  a2 s .co  m
 * @param number
 *          Number to be formatted.
 * @param javaFormat
 *          Java number format pattern.
 * @param _decimalSeparator
 *          Symbol used as decimal separator.
 * @param _groupingSeparator
 *          Symbol used as grouping separator.
 * @return Formatted string.
 */
public static String formatNumber(BigDecimal number, String javaFormat, String _decimalSeparator,
        String _groupingSeparator) {
    if (StringUtils.isEmpty(javaFormat)) {
        return formatNumber(number);
    }
    String decimalSeparator = _decimalSeparator;
    String groupingSeparator = _groupingSeparator;
    if (StringUtils.isEmpty(decimalSeparator) || StringUtils.isEmpty(groupingSeparator)) {
        decimalSeparator = ".";
        groupingSeparator = ",";
    }
    DecimalFormatSymbols dfs = new DecimalFormatSymbols();
    DecimalFormat dc;
    try {
        dfs.setDecimalSeparator(decimalSeparator.charAt(0));
        dfs.setGroupingSeparator(groupingSeparator.charAt(0));
        dc = new DecimalFormat(javaFormat, dfs);

    } catch (Exception e) {
        // If any error use euroEdition default format
        dc = new DecimalFormat("#0.00", dfs);
    }
    return dc.format(number);
}

From source file:org.openbravo.advpaymentmngt.utility.FIN_Utility.java

/**
 * Formats a number using the euroEdition (see Format.xml) format.
 * /*w w w.  j  a  v a 2 s  . c  om*/
 * @param number
 *          Number to be formatted.
 * @return Formatted string.
 */
public static String formatNumber(BigDecimal number) {
    final UIDefinitionController.FormatDefinition formatDef = UIDefinitionController.getInstance()
            .getFormatDefinition("euro", "Edition");

    String formatWithDot = formatDef.getFormat();
    DecimalFormatSymbols dfs = new DecimalFormatSymbols();
    DecimalFormat amountFormatter;
    try {
        dfs.setDecimalSeparator(formatDef.getDecimalSymbol().charAt(0));
        dfs.setGroupingSeparator(formatDef.getGroupingSymbol().charAt(0));
        // Use . as decimal separator
        final String DOT = ".";
        if (!DOT.equals(formatDef.getDecimalSymbol())) {
            formatWithDot = formatWithDot.replace(formatDef.getGroupingSymbol(), "@");
            formatWithDot = formatWithDot.replace(formatDef.getDecimalSymbol(), ".");
            formatWithDot = formatWithDot.replace("@", ",");
        }
        amountFormatter = new DecimalFormat(formatWithDot, dfs);
    } catch (Exception e) {
        // If any error use euroEdition default format
        amountFormatter = new DecimalFormat("#0.00", dfs);
    }
    return amountFormatter.format(number);
}