| | |
| | | |
| | | import java.math.RoundingMode; |
| | | import java.text.DecimalFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private List<Map<String, Object>> revise(List<Realtime> data) { |
| | | private List<Map<String, Object>> revise(List<Realtime> data) throws ParseException { |
| | | List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); |
| | | for (int i = 0; i < data.size(); i++) { |
| | | Realtime realtime = data.get(i); |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | map.put("symbol", realtime.getSymbol()); |
| | | map.put("ts", realtime.getTs()); |
| | | map.put("current_time", realtime.getCurrent_time()); |
| | | String currentTime = realtime.getCurrent_time(); |
| | | // 设置时区为纽约的冬令时(Eastern Standard Time, EST) |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | sdf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai")); |
| | | Date parsedDate = sdf.parse(currentTime); |
| | | map.put("current_time",sdf.format(parsedDate)); |
| | | map.put("name", realtime.getName()); |
| | | map.put("change_ratio", realtime.getChange_ratio()); |
| | | Item item = this.itemService.cacheBySymbol(realtime.getSymbol(), true); |