List与字符串转换

1.将list元素用单引号引起来:
List<TransferFocusxfSummaryTop3> topList = getTransferFocusxfSummaryTop3(userId);
List<String> otherSidelist=new ArrayList<String>();

for(int i=0;i<topList.size();i++){
otherSidelist.add("'"+topList.get(i).getOtherSide()+"'");
}

2.将list转化为mysql中集合查询条件in ():
("+String.join(",",otherSidelist)+")

3.mysql最近三个月数据:
t.tradetime>=DATE_SUB(now(), INTERVAL 3 MONTH)

4.BigDecimal数据类型除法并转换为百分比:
getFormatNum(amountTop3.divide(totalAmount, RoundingMode.HALF_UP).toPlainString()
百分比:
private String getFormatNum(String n) {
NumberFormat num = NumberFormat.getPercentInstance();
num.setMaximumFractionDigits(0);
return num.format(new BigDecimal(n));
}



posted @ 2016-12-30 14:44  小学生II  阅读(696)  评论(0编辑  收藏  举报