自动生成18位id:
verifyCode.setId(UniqueNumberUtils.get18UniqueNumber());
生成当前时间:
DateUtils.gettimestamp();
String转为Date类型:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date start = new Date();
try {
start = sdf.parse(startDate);
} catch (ParseException e) {
e.printStackTrace();
}
token中获取loginname:
CommonToken tokenInfo = commomTokenService.selectByToken(token);
String loginname = tokenInfo.getAccount();
判断是否为空:
string.isEmpty();
StringUtils.isEmpty(loginname);
ArrayUtils.isNotEmpty(strs);
CollectionUtils.isNotEmpty(houses);
// 判断读取的数据是否为空
Iterator<ShopInfo> iterator = shopInfos.iterator();
while(iterator.hasNext()){
ShopInfo ShopInfoSingle = (ShopInfo) iterator.next();
if (ShopInfoSingle == null) {
flag = false;
break;
} else {
flag = true;
}
}
分页:
// 指定默认为首页
if (pNo == null || pNo < OwnerConstants.PAGE_NO) {
pNo = OwnerConstants.PAGE_NO;
}
// 此处添加PageHelper将会走拦截器,进行分页,分页方法只针对紧跟着PageHelper的查询方法有效
PageHelper.startPage(pNo, OwnerConstants.PAGE_SIZE);
// 分页
PageInfo<CarBillDetail> carBillListP = new PageInfo<CarBillDetail>(carBillList);
集合的遍历器:
Iterator<CellHouse> iterator = houses.iterator();
while(iterator.hasNext()){
CellHouse house = (CellHouse) iterator.next();
housesID.add(house.getId());
}
将,分割的string分成string数组:
String[] houseIdArray = housesID.split(",");
// 计算结束时间:
Calendar cal = Calendar.getInstance();
cal.setTime(startDate);
cal.add(Calendar.MONTH, month);
Date endDate = cal.getTime();
carBillDetail.setEndDate(endDate);