@Override
public String save() {
if(customer.getCustomerNo() != null && !"".equals(customer.getCustomerNo())){
customerService.updateObject(customer);
}else{
customer.setCustomerNo(new Date().getTime().toString());
customerService.saveObject(customer);
}
return super.save();
}
customer.setCustomerNo(new Date().getTime().toString());
customerNo 本为Customer表的id,但是是String型,然而我想取得当前毫秒数转换为字符串作为id。但是报错一句Cannot invoke toString() on the primitive type long (无法调用toString()在原始类型long) 求解!
注:表的id是前人写的string型。
------解决方案--------------------------------------------------------
- Java code
System.out.println(String.valueOf(new Date().getTime())); System.out.println(new Date().getTime()+"");