价格问题处理
This commit is contained in:
@@ -160,12 +160,14 @@ public class BTodayStockController {
|
|||||||
|
|
||||||
String forObject = restTemplate.getForObject(apiUrl, String.class);
|
String forObject = restTemplate.getForObject(apiUrl, String.class);
|
||||||
JSONObject jsonObject = JSON.parseObject(forObject);
|
JSONObject jsonObject = JSON.parseObject(forObject);
|
||||||
String price = jsonObject.getString("price");
|
JSONArray arryData = jsonObject.getJSONArray("data");
|
||||||
if (price != null) {
|
if (arryData != null&&arryData.size()>0) {
|
||||||
try {
|
try {
|
||||||
|
JSONObject jsonObject1 = arryData.getJSONObject(0);
|
||||||
|
String price = jsonObject1.getString("price");
|
||||||
double priceValue = Double.parseDouble(price);
|
double priceValue = Double.parseDouble(price);
|
||||||
DecimalFormat df = new DecimalFormat("0.00");
|
DecimalFormat df = new DecimalFormat("0.00");
|
||||||
jsonObject.put("price", df.format(priceValue));
|
jsonObject1.put("price", df.format(priceValue));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// Handle the case where price is not a valid double
|
// Handle the case where price is not a valid double
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
Reference in New Issue
Block a user