List of usage examples for java.lang Float parseFloat
public static float parseFloat(String s) throws NumberFormatException
From source file:org.ext4spring.parameter.converter.simple.FloatConverter.java
@Override public <T> T toTypedValue(String stringValue, Class<T> type) { return (stringValue != null) ? type.cast(Float.parseFloat(stringValue)) : null; }
From source file:apexproject.data.DataBaseHandler.java
public DataBaseHandler() { index = 0;/* w ww . java 2s . com*/ idCounter = 1; gogn = new DayTourGogn(); data = gogn.getData(); for (int i = 0; i < data.length; i++) { boolean[] daysAvailable = new boolean[7]; for (int j = 0; j < 7; j++) { if (data[i][6].substring(j, j + 1).compareTo("1") == 0) { daysAvailable[j] = true; } } addDayTour(data[i][0], data[i][1], Integer.parseInt(data[i][2]), Integer.parseInt(data[i][3]), data[i][4], data[i][5], daysAvailable, Boolean.parseBoolean(data[i][7]), Float.parseFloat(data[i][8]), data[i][9], Float.parseFloat(data[i][10]), data[i][11]); } }
From source file:main.StratioENEI.java
private static void readFromCSV(String filename, float[][] outCustos, List<String> outCidades) throws IOException { CSVParser c = new CSVParser(new FileReader(filename), CSVFormat.EXCEL.withDelimiter(';').withNullString("")); int lineNumber; for (CSVRecord record : c) { // System.out.println(record); if ((lineNumber = (int) record.getRecordNumber()) == 1) { continue; }/*from w w w . j av a2s . c o m*/ outCidades.add(record.get(0)); // System.out.printf("\n%10s", record.get(0)); for (int i = lineNumber - 1; i < outCustos.length + 1; i++) { // System.out.printf("\t%-6s|", (record.get(i) == null) ? "null" : record.get(i)); outCustos[lineNumber - 2][i - 1] = outCustos[i - 1][lineNumber - 2] = Float .parseFloat((record.get(i) == null) ? "0.0" : record.get(i)); } } }
From source file:com.zotoh.core.util.DataUte.java
/** * @param obj/*from w ww .j a v a 2 s . com*/ * @return */ public static float toFloat(Object obj) { if (isNull(obj)) throw new RuntimeException("Null object conversion not allowed"); if (obj instanceof Float) { return (Float) obj; } else { return Float.parseFloat(obj.toString()); } }
From source file:za.ac.cput.project.hospitalmanagement.api.MedicineApi.java
@RequestMapping(value = "/addMedicine", method = RequestMethod.GET) public String SaveMedicine(HttpServletRequest request) { String medicineName = request.getParameter("medicineName"); String medicineType = request.getParameter("medicineType"); String quantity = request.getParameter("quantity"); float quantityValue = Float.parseFloat(quantity); String treatmentIDParam = request.getParameter("treatmentID"); Long treatmentID = Long.parseLong(treatmentIDParam); return service.saveMedicine(medicineName, medicineType, quantityValue, treatmentID); }
From source file:com.erpi.mdxudf.GetDateInfo.java
public Object execute(Evaluator evaluator, Argument[] arguments) { synchronized (this) { if (udfName.equals("getDateString")) { // get input string as int Object oDays = arguments[0].evaluate(evaluator); String sDays = oDays.toString(); float fDays = Float.parseFloat(sDays); int iDays = (int) fDays; //int iDays = Integer.parseInt(sDays); // create Calendar starting at 1900/01/01 and bump by input days Calendar c = Calendar.getInstance(); c.set(1900, 00, 01);//from w w w .j av a 2 s . c o m c.add(Calendar.DATE, iDays); // fomat date string SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); returnString = sdf.format(c.getTime()); } else { returnString = ""; } if (log.isDebugEnabled()) { log.debug(" returnString: " + returnString); } return returnString; } }
From source file:com.github.terma.jenkins.githubprcoveragestatus.JacocoParser.java
private float getByXpath(final String filePath, final String content, final String xpath) { try {//ww w .ja v a 2s .c o m return Float.parseFloat(XmlUtils.findInXml(content, xpath)); } catch (NumberFormatException e) { throw new IllegalArgumentException("Strange Jacoco report!\n" + "File path: " + filePath + "\n" + "Can't extract float value by XPath: " + xpath + "\n" + "from:\n" + content); } }
From source file:com.erpbi.GetDateInfo.java
public Object execute(Evaluator evaluator, Argument[] arguments) { synchronized (this) { if (udfName.equals("getDateString")) { // get input string as int Object oDays = arguments[0].evaluate(evaluator); String sDays = oDays.toString(); float fDays = Float.parseFloat(sDays); int iDays = (int) fDays; // create Calendar starting at 1900/01/01 and bump by input days Calendar c = Calendar.getInstance(); c.set(1900, 00, 01);//from w ww . j av a 2s. c o m c.add(Calendar.DATE, iDays); // format date string SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); returnString = sdf.format(c.getTime()); } else if (udfName.equals("getCurrentDays")) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); Date today = new Date(); long d1 = 0; try { d1 = sdf.parse("1900/01/01").getTime(); } catch (Exception e) { e.printStackTrace(System.out); } long d2 = today.getTime(); returnString = "" + Math.abs((d2 - d1) / (1000 * 60 * 60 * 24)); } else { returnString = ""; } if (log.isDebugEnabled()) { log.debug(" returnString: " + returnString); } return returnString; } }
From source file:ec.edu.espe.distribuidas.facturacion.socket.estrucMsj.tipoDato.Dec.java
@Override public Float getDato() { String enteroTxt = txtDecimal.substring(0, enteros); String decimalTxt = txtDecimal.substring(enteros, enteros + decimal); return Float.parseFloat(enteroTxt + "." + decimalTxt); }
From source file:com.mobilesolutionworks.android.util.TypeUtils.java
public static float parseFloat(String value, float fallback) { if (value == null || value.length() == 0) { return fallback; }/*from ww w . ja v a2 s.c o m*/ try { return Float.parseFloat(value); } catch (Exception e) { return fallback; } }