Example usage for java.lang Float valueOf

List of usage examples for java.lang Float valueOf

Introduction

In this page you can find the example usage for java.lang Float valueOf.

Prototype

@HotSpotIntrinsicCandidate
public static Float valueOf(float f) 

Source Link

Document

Returns a Float instance representing the specified float value.

Usage

From source file:twitterGateway_v2_06.java

public void TwitterToOsc(String TwitterSender, String TwitterMessage) {
    //TwitterSender = trim(TwitterSender.replaceAll("[^\\p{ASCII}]","*"));
    //TwitterMessage = trim(TwitterMessage.replaceAll("[^\\p{ASCII}]","*"));
    OscMessage SendOscMessage = new OscMessage(OscSendAddress);
    SendOscMessage.add(TwitterSender);//from w ww . java 2  s  .c om
    //SendOscMessage.add(TwitterMessage);
    String[] OscMessageArguments = { "" };
    if (SplitMessages == false) {
        OscMessageArguments[0] = TwitterMessage;
        SendOscMessage.add(OscMessageArguments[0]);
    } else {
        OscMessageArguments = split(TwitterMessage, ' ');
        for (int i = 0; i < OscMessageArguments.length; i++) {
            try {
                float f = Float.valueOf(OscMessageArguments[i].trim()).floatValue();
                SendOscMessage.add(f);
            } catch (NumberFormatException nfe) {
                SendOscMessage.add(OscMessageArguments[i]);
            }

            //SendOscMessage.add(OscMessageArguments[i]);
        }
    }
    oscP5.send(SendOscMessage, OscDestination);
    ActivityLogAddLine("OSC SEND " + OscSendAddress + " " + TwitterSender + " " + TwitterMessage);
}

From source file:br.gov.frameworkdemoiselle.ldap.internal.ClazzUtils.java

public static Object getValueAsFieldType(Field field, Object values, boolean cascade) {
    if (values instanceof String[]) {
        String[] valueArray = (String[]) values;

        if (valueArray == null || valueArray.length == 0)
            return null;

        if (field.getType().isAssignableFrom(String.class))
            return valueArray[0];

        if (field.getType().isArray())
            if (field.getType().getComponentType().isAssignableFrom(String.class))
                return valueArray;

        if (field.getType().isPrimitive()) {

            if (field.getType().isAssignableFrom(int.class))
                return Integer.valueOf(valueArray[0]);

            if (field.getType().isAssignableFrom(long.class))
                return Long.valueOf(valueArray[0]);

            if (field.getType().isAssignableFrom(double.class))
                return Double.valueOf(valueArray[0]);

            if (field.getType().isAssignableFrom(float.class))
                return Float.valueOf(valueArray[0]);

            if (field.getType().isAssignableFrom(short.class))
                return Short.valueOf(valueArray[0]);

            if (field.getType().isAssignableFrom(byte.class))
                return Byte.valueOf(valueArray[0]);

        }/*from ww  w .j a va2  s.c o  m*/

        if (isAnnotationPresent(field.getType(), LDAPEntry.class, false))
            return getMappedEntryObject(field.getType(), valueArray, cascade);

        if (field.getType().isAssignableFrom(ArrayList.class))
            if (String.class.isAssignableFrom(Reflections.getGenericTypeArgument(field.getType(), 0)))
                return new ArrayList<String>(Arrays.asList(valueArray));

        if (field.getType().isAssignableFrom(Integer.class))
            return Integer.valueOf(valueArray[0]);

        if (field.getType().isAssignableFrom(Long.class))
            return Long.valueOf(valueArray[0]);

        if (field.getType().isAssignableFrom(Double.class))
            return Double.valueOf(valueArray[0]);

        if (field.getType().isAssignableFrom(Float.class))
            return Float.valueOf(valueArray[0]);

        if (field.getType().isAssignableFrom(Short.class))
            return Short.valueOf(valueArray[0]);

        if (field.getType().isAssignableFrom(Byte.class))
            return Byte.valueOf(valueArray[0]);

        logger.error("Handling not implemented for field " + field.getName() + " with type "
                + field.getType().getSimpleName());

    } else if (values instanceof byte[][]) {

        if (field.getType().isAssignableFrom(byte[][].class))
            return values;

        if (field.getType().isAssignableFrom(byte[].class))
            return ((byte[][]) values)[0];

        logger.error("Binary data from LDAP can't be set in " + field.getName() + " with type "
                + field.getType().getSimpleName());

    }

    logger.error("Object value should be String[] or byte[][]. The value type " + values.getClass()
            + " can't be set in " + field.getName() + " with type " + field.getType().getSimpleName());
    return null;
}

From source file:org.geomajas.plugin.rasterizing.layer.RasterDirectLayer.java

private float getOpacity() {
    String match = style;/*from w  ww . j  a va 2s . c  o m*/
    // could be 'opacity:0.5;' or '0.5'
    if (style.contains(OPACITY)) {
        match = style.substring(style.indexOf(OPACITY) + OPACITY.length());
    }
    int semiColonPosition = match.indexOf(';');
    if (semiColonPosition >= 0) {
        match = match.substring(0, semiColonPosition);
    }
    try {
        return Float.valueOf(match);
    } catch (NumberFormatException nfe) {
        log.warn("Could not parse opacity " + style + "of raster layer " + getTitle());
        return 1f;
    }
}

From source file:i5.las2peer.services.videoAdapter.AdapterClass.java

@GET
@Path("VideoPlaylist")
public HttpResponse getVideoPlaylist(@QueryParam(name = "search", defaultValue = "*") String searchString,
        @QueryParam(name = "Authorization", defaultValue = "") String token) {

    String username = null;//from  w  w  w .j  a  v a 2s . c o m

    System.out.println("TOKEN: " + token);

    if (token != null) {
        token = token.replace("Bearer ", "");
        username = OIDC.verifyAccessToken(token, userinfo);
    }

    System.out.println("SeViAnno Checkpoint:0 -- request received" + " - User: " + username
            + " - Search Query: " + searchString);

    //User validation

    if (username.isEmpty() || username.equals("undefined") || username.equals("error")) {
        HttpResponse r = new HttpResponse("User is not signed in!");
        r.setStatus(401);
        return r;
    }
    if (searchString.isEmpty() || searchString.equals("undefined")) {
        HttpResponse r = new HttpResponse("Please enter a valid search query!");
        r.setStatus(400);
        return r;
    }
    //String annotations = "No Annotation";

    // Get the annotations
    String requestURI = "http://eiche:7073/annotations/annotations?q=" + searchString.replaceAll(" ", ",")
            + "&part=duration,weight,id,objectCollection,domain,location,objectId,text,time,title,keywords&collection=TextTypeAnnotation";
    String content = Adapt.getResponse(requestURI);

    // Parse Response to JSON
    JSONArray finalResult = new JSONArray(content);
    String[] objectIds = new String[finalResult.length()];

    int i = 0;
    while (!finalResult.isNull(i)) {
        JSONObject object = finalResult.getJSONObject(i);

        if (!"Videos".equals(object.getString("objectCollection"))) {
            finalResult.remove(i);
        } else {
            // Get the object Ids from the response
            objectIds[i] = new String(object.getString("objectId"));

            i++;
        }
    }
    System.out.println("SeViAnno Checkpoint:1 -- non-video annotations removed, ObjectId obtained.");

    objectIds = new HashSet<String>(Arrays.asList(objectIds)).toArray(new String[0]);

    int size = objectIds.length;

    // Get Video URLs

    String[] videos = new String[size];
    videos = Adapt.getVideoURLs(objectIds, size);

    // Append Video URLs
    /*JSONObject object;
    for(int k=0;k<size;k++){
       object = finalResult.getJSONObject(k);
       object.append("videoURL", videos[k]);
    }*/

    //JsonElement root1 = new JsonParser().parse(object.toString());
    //JsonObject o3 = root1.getAsJsonObject();

    //JSONArray annotations = new JSONArray();
    JsonArray annotationArray = new JsonArray();
    for (int j = 0; j < size; j++) {
        String objectRequestURI = "http://eiche:7073/annotations/objects/" + objectIds[j] + "/annotations";
        String objectContent = Adapt.getResponse(objectRequestURI);

        JsonElement root = new JsonParser().parse(objectContent);
        JsonObject jsonObject = root.getAsJsonObject();

        JsonArray jsonArray = jsonObject.getAsJsonArray("annotations");

        //System.out.println("Array: "+jsonArray.toString());
        //System.out.println("length: "+jsonArray.size());

        JsonObject o3 = new JsonObject();
        o3.addProperty("videoURL", videos[j]);

        System.out.println("Before Loop!");

        annotationArray.add(o3);
        JsonArray childAnnotationArray = new JsonArray();
        for (int loop1 = 0; loop1 < jsonArray.size(); loop1++) {

            JsonObject annotationObject = new JsonObject();

            JsonObject o1 = jsonArray.get(loop1).getAsJsonObject();

            //System.out.println("o1: "+o1);
            JsonObject ann = o1.get("annotation").getAsJsonObject();
            JsonArray annContext = o1.get("annotationContexts").getAsJsonArray();

            System.out.println("In Loop " + loop1 + ", ann: " + o1.get("annotation").toString());
            System.out.println("In Loop, annContext: " + o1.get("annotationContexts").toString());

            //System.out.println("ann: "+ann.toString());
            annotationObject.addProperty("id", ann.get("id").getAsString());
            annotationObject.addProperty("text", ann.get("text").getAsString());
            annotationObject.addProperty("title", ann.get("title").getAsString());
            annotationObject.addProperty("keywords", ann.get("keywords").getAsString());

            System.out.println("id: " + ann.get("id").getAsString() + " text: " + ann.get("text").getAsString()
                    + " title: " + ann.get("title").getAsString() + " keywords: "
                    + ann.get("keywords").getAsString());

            annotationObject.addProperty("duration",
                    annContext.get(0).getAsJsonObject().get("duration").getAsString());
            System.out
                    .println("duration: " + annContext.get(0).getAsJsonObject().get("duration").getAsString());

            annotationObject.addProperty("time", annContext.get(0).getAsJsonObject().get("time").getAsString());

            System.out.println("time: " + annContext.get(0).getAsJsonObject().get("time").getAsString());

            float time, duration;

            time = Float.valueOf(annContext.get(0).getAsJsonObject().get("time").getAsString());
            System.out.println("FloatTime: " + time);
            duration = Float.valueOf(annContext.get(0).getAsJsonObject().get("duration").getAsString());
            System.out.println("FloatDuration: " + duration);
            float endtime = duration + time;

            System.out.println("Endtime: " + endtime);

            annotationObject.addProperty("videoURL", videos[j] + "#t=" + time + "," + endtime);

            System.out.println("VideoURL: " + videos[j] + "#t=" + time + "," + endtime);

            childAnnotationArray.add(annotationObject);
        }
        annotationArray.add(childAnnotationArray);

        System.out.println("After Loop!  " + annotationArray.toString());

    }

    HttpResponse r = new HttpResponse(annotationArray.toString());
    r.setStatus(200);
    return r;

}

From source file:com.linkedin.pinot.core.segment.index.loader.defaultcolumn.BaseDefaultColumnHandler.java

/**
 * Helper method to create the V1 indices (dictionary and forward index) for a column.
 *
 * @param column column name./* www  . ja v a  2s .com*/
 */
protected void createColumnV1Indices(String column) throws Exception {
    FieldSpec fieldSpec = schema.getFieldSpecFor(column);
    boolean isSingleValue = fieldSpec.isSingleValueField();

    // Generate column index creation information.
    int totalDocs = segmentMetadata.getTotalDocs();
    int totalRawDocs = segmentMetadata.getTotalRawDocs();
    int totalAggDocs = totalDocs - totalRawDocs;
    Object defaultValue = fieldSpec.getDefaultNullValue();
    String stringDefaultValue = defaultValue.toString();
    FieldSpec.DataType dataType = fieldSpec.getDataType();
    int maxNumberOfMultiValueElements = isSingleValue ? 0 : 1;
    int dictionaryElementSize = 0;
    Object sortedArray;

    switch (dataType) {
    case BOOLEAN:
    case STRING:
        // Length of the UTF-8 encoded byte array.
        dictionaryElementSize = stringDefaultValue.getBytes("UTF8").length;
        sortedArray = new String[] { stringDefaultValue };
        break;
    case INT:
        sortedArray = new int[] { Integer.valueOf(stringDefaultValue) };
        break;
    case LONG:
        sortedArray = new long[] { Long.valueOf(stringDefaultValue) };
        break;
    case FLOAT:
        sortedArray = new float[] { Float.valueOf(stringDefaultValue) };
        break;
    case DOUBLE:
        sortedArray = new double[] { Double.valueOf(stringDefaultValue) };
        break;
    default:
        throw new UnsupportedOperationException(
                "Schema evolution not supported for data type:" + fieldSpec.getDataType());
    }
    ColumnIndexCreationInfo columnIndexCreationInfo = new ColumnIndexCreationInfo(true/*createDictionary*/,
            defaultValue/*min*/, defaultValue/*max*/, sortedArray, ForwardIndexType.FIXED_BIT_COMPRESSED,
            InvertedIndexType.SORTED_INDEX, isSingleValue/*isSortedColumn*/, false/*hasNulls*/,
            totalDocs/*totalNumberOfEntries*/, maxNumberOfMultiValueElements, true/*isAutoGenerated*/,
            defaultValue/*defaultNullValue*/);

    // Create dictionary.
    // We will have only one value in the dictionary.
    SegmentDictionaryCreator segmentDictionaryCreator = new SegmentDictionaryCreator(false/*hasNulls*/,
            sortedArray, fieldSpec, indexDir, V1Constants.Str.DEFAULT_STRING_PAD_CHAR);
    segmentDictionaryCreator.build(new boolean[] { true }/*isSorted*/);
    segmentDictionaryCreator.close();

    // Create forward index.
    if (isSingleValue) {
        // Single-value column.

        SingleValueSortedForwardIndexCreator svFwdIndexCreator = new SingleValueSortedForwardIndexCreator(
                indexDir, 1/*cardinality*/, fieldSpec);
        for (int docId = 0; docId < totalDocs; docId++) {
            svFwdIndexCreator.add(0/*dictionaryId*/, docId);
        }
        svFwdIndexCreator.close();
    } else {
        // Multi-value column.

        MultiValueUnsortedForwardIndexCreator mvFwdIndexCreator = new MultiValueUnsortedForwardIndexCreator(
                fieldSpec, indexDir, 1/*cardinality*/, totalDocs/*numDocs*/, totalDocs/*totalNumberOfValues*/,
                false/*hasNulls*/);
        int[] dictionaryIds = { 0 };
        for (int docId = 0; docId < totalDocs; docId++) {
            mvFwdIndexCreator.index(docId, dictionaryIds);
        }
        mvFwdIndexCreator.close();
    }

    // Add the column metadata information to the metadata properties.
    SegmentColumnarIndexCreator.addColumnMetadataInfo(segmentProperties, column, columnIndexCreationInfo,
            totalDocs, totalRawDocs, totalAggDocs, fieldSpec, dictionaryElementSize, true/*hasInvertedIndex*/,
            null/*hllOriginColumn*/);
}

From source file:de.iteratec.svg.SvgGraphicWriter.java

/**
 * Scales down the width used to set the size of a resulting raster image export.
 * The width is scaled down so that the product of width and height does not exceed
 * the value given by the RASTER_TRANSCODER_MAX_AREA. This is necessary, so that
 * image transcoding does not throw an exception and no heap space issues occur.
 * //from  www . j ava  2  s.com
 * @param width
 *    The original width of the SVG graphic.
 * @param height
 *    The original height of the SVG graphic.
 */
private static void setScaledImageTranscoderDimensions(ImageTranscoder transcoder, Double width,
        Double height) {
    if (width != null && height != null) {
        long scaledWidth = width.longValue();
        long scaledHeight = height.longValue();

        if (scaledHeight * scaledWidth > RASTER_TRANSCODER_MAX_AREA) {
            double aspectRatio = (double) scaledHeight / scaledWidth;
            while (scaledHeight * scaledWidth > RASTER_TRANSCODER_MAX_AREA) {
                scaledWidth = scaledWidth - RASTER_TRANSCODER_STEP;
                scaledHeight = (long) Math.ceil(scaledWidth * aspectRatio);
            }
        }

        transcoder.addTranscodingHint(PNGTranscoder.KEY_WIDTH, Float.valueOf(scaledWidth));
        transcoder.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, Float.valueOf(scaledHeight));
    }
}

From source file:com.gmail.srivi.sundaram.locgenie.MainActivity.java

public void getSuggestion(View v) {

    if (servicesConnected()) {
        Log.d(" ", "In getSuggestions_new");
        EditText radius = (EditText) findViewById(R.id.editText1);
        String radiusCheck = radius.getText().toString();
        // Getting the Selected Activity
        RadioGroup rg = (RadioGroup) findViewById(R.id.radioGroup1);
        RadioButton selected = (RadioButton) findViewById(rg.getCheckedRadioButtonId());
        String activity = (String) selected.getText();
        if (radiusCheck.isEmpty()) {
            Toast.makeText(this, "Please Enter Radius", Toast.LENGTH_SHORT).show();
        } else {//ww w.j ava  2s  . c om
            float miles = Float.valueOf(radius.getText().toString());
            float meters = (float) (miles * 1609.344);
            String radiusInMeters = Float.toString(meters);
            Location currentLocation = mLocationClient.getLastLocation();
            Intent intent = new Intent(getBaseContext(), DisplayPlacesActivity.class);
            intent.putExtra(EXTRA_MESSAGE, currentLocation);
            intent.putExtra(RADIUS, radiusInMeters);
            intent.putExtra(ACTIVITY, activity);
            startActivity(intent);
        }

    }
}

From source file:com.jada.order.document.CreditEngine.java

public void setQty(String itemSkuCd, int qty) throws Exception {
    CreditDetail creditDetail = null;/*  w  ww  .  j  ava  2 s.c o m*/
    boolean found = false;
    Iterator<?> iterator = creditHeader.getCreditDetails().iterator();
    while (iterator.hasNext()) {
        creditDetail = (CreditDetail) iterator.next();
        if (creditDetail.getOrderItemDetail().getItemSkuCd().equals(itemSkuCd)) {
            found = true;
            break;
        }
    }
    if (!found) {
        creditDetail = new CreditDetail();
        creditDetail.setRecCreateBy(user.getUserId());
        creditDetail.setRecCreateDatetime(new Date());
        iterator = orderHeader.getOrderItemDetails().iterator();
        found = false;
        while (iterator.hasNext()) {
            OrderItemDetail orderItemDetail = (OrderItemDetail) iterator.next();
            if (orderItemDetail.getItemSkuCd().equals(itemSkuCd)) {
                creditDetail.setOrderItemDetail(orderItemDetail);
                //               orderItemDetail.getCreditDetails().add(creditDetail);
                found = true;
                break;
            }
        }
        if (!found) {
            throw new OrderItemNotFoundException("");
        }
        creditDetail.setCreditHeader(creditHeader);

        iterator = creditHeader.getCreditDetails().iterator();
        int seqNum = 0;
        while (iterator.hasNext()) {
            CreditDetail c = (CreditDetail) iterator.next();
            if (c.getSeqNum() > seqNum) {
                seqNum = c.getSeqNum();
            }
        }
        creditDetail.setSeqNum(seqNum);
        creditHeader.getCreditDetails().add(creditDetail);
    }

    ItemBalance itemBalance = getItemBalance(orderHeader, itemSkuCd, null, creditHeader, null);
    int balanceQty = itemBalance.getInvoiceQty() - itemBalance.getCreditQty();
    float balanceAmount = itemBalance.getInvoiceAmount() - itemBalance.getCreditAmount();

    if (balanceQty < qty) {
        throw new OrderQuantityException("");
    }
    creditDetail.setItemCreditQty(qty);
    if (balanceQty == qty) {
        creditDetail.setItemCreditAmount(balanceAmount);
    } else {
        float itemCreditAmount = Utility.round(balanceAmount * qty / balanceQty, 2);
        creditDetail.setItemCreditAmount(itemCreditAmount);
    }

    creditDetail.getCreditDetailTaxes().clear();
    ItemTaxBalance itemTaxBalances[] = itemBalance.getItemTaxBalances();
    for (int i = 0; i < itemTaxBalances.length; i++) {
        ItemTaxBalance itemTaxBalance = itemTaxBalances[i];
        float taxBalanceAmount = itemTaxBalance.getInvoiceTaxAmount() - itemTaxBalance.getCreditTaxAmount();
        if (taxBalanceAmount <= 0) {
            continue;
        }
        CreditDetailTax creditDetailTax = new CreditDetailTax();
        creditDetailTax.setCreditHeader(creditHeader);
        creditDetailTax.setCreditDetail(creditDetail);
        creditDetail.getCreditDetailTaxes().add(creditDetailTax);
        creditDetailTax.setTax(itemTaxBalance.getTax());
        creditDetailTax.setTaxName(itemTaxBalance.getTaxName());
        if (balanceQty == qty) {
            creditDetailTax.setTaxAmount(Float.valueOf(taxBalanceAmount));
        } else {
            float taxInvoiceAmount = Utility.round(taxBalanceAmount * qty / balanceQty, 2);
            creditDetailTax.setTaxAmount(Float.valueOf(taxInvoiceAmount));
        }
        creditDetailTax.setRecUpdateBy(user.getUserId());
        creditDetailTax.setRecUpdateDatetime(new Date());
        creditDetailTax.setRecCreateBy(user.getUserId());
        creditDetailTax.setRecCreateDatetime(new Date());
        creditHeader.getCreditTaxes().add(creditDetailTax);
    }
    creditDetail.setRecUpdateBy(user.getUserId());
    creditDetail.setRecUpdateDatetime(new Date());
    creditHeader.setRecUpdateBy(user.getUserId());
    creditHeader.setRecUpdateDatetime(new Date());

    lastCreditDetail = creditDetail;
}

From source file:org.openurp.thesis.service.impl.CnkiThesisCheckServiceImpl.java

/**
 * ?// w ww.  j a va2 s.  c  o m
 * 
 * @param text
 * @return
 */
protected List<CheckResult> extract(String text) {
    Matcher m = checkPattern.matcher(text);
    List<CheckResult> results = new ArrayList<CheckResult>();
    // [2]id:value="id"
    // [5]article:<a>article</a>
    // [8]author:<a>author</a>
    // [11]content:<div title="?">0%</div><div title="??">0</div>
    // [14]date
    // [17]downloadurl:<a target="_blank"
    // href=" http://checkdownload.cnki.net/thesisdownload/?downType=0&user=yourname&userServerID=1&fileID=fileId&check=5f6cad62f7fa352955321bc1b4989912"
    // >
    while (m.find()) {
        String content = m.group(11);
        long id = Long.valueOf(StringUtils.substringBetween(m.group(2), "value=\"", "\""));
        String thesis = StringUtils.substringBetween(m.group(5), ">", "</a>");
        String author = StringUtils.substringBetween(m.group(8), ">", "</a>");
        if (content.contains("?")) {
            String ratioStr = StringUtils.substringBetween(content, "?\">", "%</div>");
            float ratio = Float.valueOf(ratioStr) / 100;
            int count = Integer.valueOf(StringUtils.substringBetween(content, "??\">", "</div>"));
            Date checkOn = Date.valueOf(m.group(14).trim());
            String checksum = StringUtils.substringBetween(m.group(17), "check=", "\"");
            results.add(new CheckResult(id, thesis, author, checksum, checkOn, ratio, count));
        } else {
            Date checkOn = Date.valueOf(m.group(14).trim());
            String checksum = StringUtils.substringBetween(m.group(17), "check=", "\"");
            results.add(new CheckResult(id, thesis, author, checksum, checkOn));
        }

    }
    return results;
}

From source file:abelymiguel.miralaprima.GetPrima.java

private HashMap<String, Float> getPrimaDataDMacro(String country_code, String providerUrl, String indexName)
        throws IOException {
    HashMap<String, Float> respuestaJson = new HashMap<String, Float>();
    HashMap<String, Object> primaJson;

    Float prima_value;//from  w  w w  .  jav a2  s .  com
    Float prima_delta;
    Float prima_percent;

    Document doc;
    doc = Jsoup.connect(providerUrl + indexName).get();

    try {
        Element riskPremium = doc.select(".numero").first();
        //                System.out.println("Prima: " + riskPremium.text());
        prima_value = Float.valueOf(riskPremium.text().replace(".", "")).floatValue();

        Element riskDelta = doc.select(".text-success").first();
        String deltaStr = riskDelta.text().substring(riskDelta.text().indexOf(">") + 1);
        prima_delta = Float.valueOf(deltaStr).floatValue();
        //                System.out.println("Trending delta: " + prima_delta);

        String percentStr;
        prima_percent = 100 * prima_delta / (prima_value - prima_delta);
        DecimalFormat df = new DecimalFormat("0.00");
        percentStr = df.format(prima_percent);
        prima_percent = Float.valueOf(percentStr).floatValue();
        //                System.out.println("Trending prima_percent: " + prima_percent);

        respuestaJson.put("prima_value", prima_value);
        respuestaJson.put("prima_delta", prima_delta);
        respuestaJson.put("prima_percent", prima_percent);

        if (isSameDay(country_code)) {
            this.updatePrimaInDB(prima_value, prima_delta, prima_percent,
                    this.getLatestPrimaIdFromDB(country_code));

        } else {
            this.storePrimaInDB(prima_value, prima_delta, prima_percent, country_code);
        }
    } catch (Exception ex) {
        Logger.getLogger(GetPrima.class.getName()).log(Level.SEVERE, null, ex);
        primaJson = getLatestPrimaFromDB(country_code);
        respuestaJson.put("prima_value", (Float) primaJson.get("prima_value"));
        respuestaJson.put("prima_delta", (Float) primaJson.get("prima_delta"));
        respuestaJson.put("prima_percent", (Float) primaJson.get("prima_percent"));
    }

    return respuestaJson;

}