List of usage examples for java.lang Double parseDouble
public static double parseDouble(String s) throws NumberFormatException
From source file:web.Controller.AddAccountController.java
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object commandAddAccount, BindException errors) throws Exception { CommandAddAccount command = (CommandAddAccount) commandAddAccount; Compte compte = new Compte(); compte.setDateOuverture(new Date()); try {/*from ww w . j ava 2 s.co m*/ compte.setSolde(Double.parseDouble(command.getSolde())); addaccountservice.addAccount(compte, command.getPass()); return new ModelAndView("accountcreationsuccess", "compte", compte); } catch (DisabledUserProfileException e) { errors.reject("Disabled Profile", "Your Profile is Disabled this action is forbidden"); return showForm(request, response, errors); } catch (WrongPasswordException e) { errors.reject("Wrong Password", "Your Password is Wrong"); return showForm(request, response, errors); } catch (java.lang.NumberFormatException e) { errors.reject("NumberFormatException", "amount is invalid"); return showForm(request, response, errors); } }
From source file:com.gamersrepublic.services.impl.OrderServiceImpl.java
@Override public OrderItem addOrder(Map model, List<Paper> pages) { if (!pages.isEmpty()) { productRepo = ctx.getBean(ProductRepository.class); orderItemRepo = ctx.getBean(OrderItemRepository.class); Product product = new Product.Builder(model.get("type").toString()).paperUsed(pages) .unitPrice(Double.parseDouble(model.get("price").toString())).build(); productRepo.save(product);/*from ww w. ja v a 2 s.c o m*/ OrderItem orderItem = new OrderItem.Builder(Integer.parseInt(model.get("quantity").toString())) .product(product).build(); orderItemRepo.save(orderItem); return orderItemRepo.findOne(orderItem.getId()); } else { return null; } }
From source file:com.tempescope.wunderground.WeatherLocation.java
public WeatherLocation(JSONObject obj) { full = "" + obj.get("full"); state = "" + obj.get("state"); country_iso3166 = "" + obj.get("country_iso3166"); country = "" + obj.get("country"); city = "" + obj.get("city"); coord = new Coordinate(Double.parseDouble("" + obj.get("longitude")), Double.parseDouble("" + obj.get("latitude"))); }
From source file:demo.SsMapper.java
@Override public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { String[] tokens = value.toString().split(","); System.out.println("Array contents " + Arrays.toString(tokens)); String symbol = tokens[0].trim(); System.out.println("Symbol " + symbol); Long timestamp = Long.parseLong(tokens[1].trim()); System.out.println("timestamp " + timestamp); Double v = Double.parseDouble(tokens[2].trim()); System.out.println("double " + v); StockKey stockKey = new StockKey(symbol, timestamp); DoubleWritable stockValue = new DoubleWritable(v); context.write(stockKey, stockValue); _log.debug(stockKey.toString() + " => " + stockValue.toString()); }
From source file:edu.utah.bmi.ibiomes.local.test.TestCommon.java
/** * //w ww.j a v a 2s . com * @param metadata * @param avu * @return */ private static boolean hasSameFloatValue(MetadataAVUList metadata, MetadataAVU avu) { try { double fValue1 = 0.0; fValue1 = Double.parseDouble(avu.getValue()); fValue1 = Math.round(fValue1 * 1000) / 1000; List<String> values = metadata.getValues(avu.getAttribute()); if (values != null) { for (String value : values) { double fValue2 = Double.parseDouble(value); fValue2 = Math.round(fValue2 * 1000) / 1000; if (fValue2 == fValue1) return true; } } return false; } catch (NumberFormatException e) { return false; } }
From source file:evaluation.loadGenerator.randomVariable.Weibull.java
public Weibull(String[] parameters) { super(parameters); if (parameters.length != numberOfParameters) throw new RuntimeException(errorMessage); try {/*w w w .j a v a 2s .c o m*/ this.shape = Double.parseDouble(parameters[0]); this.scale = Double.parseDouble(parameters[1]); // test: this.randomDataImpl.nextWeibull(shape, scale); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(errorMessage); } }
From source file:de.topobyte.utilities.apache.commons.cli.parsing.ArgumentHelper.java
public static double parseDouble(String value) throws ArgumentParseException { try {// w w w . jav a2s . c o m return Double.parseDouble(value); } catch (NumberFormatException e) { throw new ArgumentParseException("unable to parse double: '" + value + "'"); } }
From source file:com.metrink.MetricFactory.java
public Metric generateMetric(final String groupName, final String name, final String value, final String units) { return generateMetric(groupName, name, Double.parseDouble(value), units); }
From source file:com.cloudmine.api.CMGeoPoint.java
@JsonAnySetter protected void setWithOtherKey(String key, String value) { try {/*from ww w . ja v a 2 s. co m*/ double asDouble = Double.parseDouble(value); setWithOtherKey(key, asDouble); } catch (NumberFormatException e) { } }
From source file:ca.uqam.inf4375.springboot_example.ItemController.java
/** * Create a new item./* www . jav a2s . c o m*/ */ @RequestMapping(method = RequestMethod.POST) Map<String, Object> createItem(@RequestBody Map<String, Object> albumMap) { // FIXME input should be verified and sanitized! Item item = new Item(albumMap.get("title").toString(), Double.parseDouble(albumMap.get("price").toString())); repository.save(item); Map<String, Object> response = new HashMap<>(); response.put("message", "Item created successfully"); response.put("item", item); return response; }