Browse Source

日期保留小数点

tianyunperfect 3 years ago
parent
commit
898bbf4bc3

+ 10 - 7
book-server/src/main/java/com/book/server/service/impl/SunDataServiceImpl.java

@@ -769,10 +769,10 @@ public class SunDataServiceImpl implements SunDataService {
         example.page(page, size);
         List<SunStaticIncome> sunStaticIncomes = sunStaticIncomeMapper.selectByExample(example);
         //保留小数点
-        //for (SunStaticIncome sunStaticIncome : sunStaticIncomes) {
-        //    DecimalFormat df = new DecimalFormat("#.00");//此为保留2位小数
-        //    sunStaticIncome.setAllRecharge(df.format(sunStaticIncome.getAllRecharge()));
-        //}
+        for (SunStaticIncome sunStaticIncome : sunStaticIncomes) {
+            DecimalFormat df = new DecimalFormat("0.00");//此为保留2位小数
+            sunStaticIncome.setAllRecharge(df.format(Double.parseDouble(sunStaticIncome.getAllRecharge())));
+        }
 
         //查询另一张表对应的前 60 天的数据
         List<String> collect = sunStaticIncomes.stream().map(SunStaticIncome::getStaticDate).collect(Collectors.toList());
@@ -1060,8 +1060,11 @@ public class SunDataServiceImpl implements SunDataService {
         Gson gson = gsonBuilder.setDateFormat("yyyy-MM-dd HH:mm:ss").create();
         SunOrder sunOrder = gson.fromJson(line, SunOrder.class);
         System.out.println(sunOrder);*/
-        Map map = new HashMap();
-        map.put(new Integer(1), "sss");
-        System.out.println(map.containsKey(new Integer(1)));
+        //Map map = new HashMap();
+        //map.put(new Integer(1), "sss");
+        //System.out.println(map.containsKey(new Integer(1)));
+        DecimalFormat df = new DecimalFormat("0.00");//此为保留2位小数
+        System.out.println(df.format(Double.parseDouble("0")));
+        //    sunStaticIncome.setAllRecharge(df.format(sunStaticIncome.getAllRecharge()));
     }
 }