当前位置: 技术问答>java相关
请问这个bean有何错?
来源: 互联网 发布时间:2015-11-05
本文导语: package work; import java.util.*; public class NewNo { private String sNewNo; public NewNo() { sNewNo=""; } // public void setsNewNo(String sheetno) { // sNewNo=sheetno; // } public String ...
package work;
import java.util.*;
public class NewNo {
private String sNewNo;
public NewNo() {
sNewNo="";
}
// public void setsNewNo(String sheetno) {
// sNewNo=sheetno;
// }
public String makeNewNo(String sHead){
Calendar today=Calendar.getInstance();
int year,month,date,hour,minute,second;
year=today.get(Calendar.YEAR);
month=today.get(Calendar.MONTH)+1;
date=today.get(Calendar.DATE);
hour=today.get(Calendar.HOUR);
minute=today.get(Calendar.MINUTE);
second=today.get(Calendar.SECOND);
sNewNo=sHead+year+"_"+month+"_"+date+"_"+hour+minute+second;
return sNewNo;
}
}
import java.util.*;
public class NewNo {
private String sNewNo;
public NewNo() {
sNewNo="";
}
// public void setsNewNo(String sheetno) {
// sNewNo=sheetno;
// }
public String makeNewNo(String sHead){
Calendar today=Calendar.getInstance();
int year,month,date,hour,minute,second;
year=today.get(Calendar.YEAR);
month=today.get(Calendar.MONTH)+1;
date=today.get(Calendar.DATE);
hour=today.get(Calendar.HOUR);
minute=today.get(Calendar.MINUTE);
second=today.get(Calendar.SECOND);
sNewNo=sHead+year+"_"+month+"_"+date+"_"+hour+minute+second;
return sNewNo;
}
}
|
哦,我明白了:
首先:
和
不能混用
用:
时
要有对象:
NewNo NewNo=new NewNo();
String sNo=NewNo.makeNewNo("GBGL");
用:
时
String sNo=NewNoBean.makeNewNo("GBGL");
就可以了
首先:
和
不能混用
用:
时
要有对象:
NewNo NewNo=new NewNo();
String sNo=NewNo.makeNewNo("GBGL");
用:
时
String sNo=NewNoBean.makeNewNo("GBGL");
就可以了
|
sNewNo=sHead+year+"_"+month+"_"+date+"_"+hour+minute+second;
year,month...等
String.valueOf(year),...
year,month...等
String.valueOf(year),...
|
private String sNewNo;
改成
protected String sNewNo = null;
sNewNo=sHead+year+"_"+month+"_"+date+"_"+hour+minute+second;
改成
this.sNewNo=sHead+year+"_"+month+"_"+date+"_"+hour+minute+second;
试试
改成
protected String sNewNo = null;
sNewNo=sHead+year+"_"+month+"_"+date+"_"+hour+minute+second;
改成
this.sNewNo=sHead+year+"_"+month+"_"+date+"_"+hour+minute+second;
试试