当前位置: 技术问答>java相关
急问,关于日期存储的问题!
来源: 互联网 发布时间:2015-01-02
本文导语: 页面上设置3个text,让用户添入年,月,日。 怎样从页面上验证数据的合理性? 然后写入SQL数据库中名为productinbillofdocument的表单的indate列中????? (indate属性是日期/时间) | class controlLengthDo...
页面上设置3个text,让用户添入年,月,日。
怎样从页面上验证数据的合理性?
然后写入SQL数据库中名为productinbillofdocument的表单的indate列中?????
(indate属性是日期/时间)
怎样从页面上验证数据的合理性?
然后写入SQL数据库中名为productinbillofdocument的表单的indate列中?????
(indate属性是日期/时间)
|
class controlLengthDocument extends PlainDocument {
private JTextComponent textComponent;
private int nLength = 10;
private String strType = new String(); // Store type
boolean bFlag = false;
private int nMin = 0;
private int nMax = 0;
private int nLimitLength = 0;
public controlLengthDocument(JTextComponent textComponentPara) {
textComponent = textComponentPara;
}
public controlLengthDocument(JTextComponent textComponentPara, int nLengthPara) {
textComponent = textComponentPara;
nLength = nLengthPara;
}
public controlLengthDocument(JTextComponent textComponentPara, int nLengthPara, String strTypePara) {
textComponent = textComponentPara;
nLength = nLengthPara;
strType = strTypePara;
}
public controlLengthDocument(JTextComponent textComponentPara, int nLengthPara, String strTypePara, int nMinPara, int nMaxPara) {
textComponent = textComponentPara;
nLength = nLengthPara;
strType = strTypePara;
nMin = nMinPara;
nMax = nMaxPara;
bFlag = true;
nLimitLength = Integer.toString(nMin).length();
}
public void insertString(int nOffsetPara, String strPara,AttributeSet attributeSetPara)
throws BadLocationException {
if (strType.equals("int")) {
try{
Integer.parseInt(strPara);
}catch(Exception ex){
return;
}
}
if (nOffsetPara >= (nLength - nLimitLength)) {
if(bFlag) {
int nValue = Integer.parseInt(textComponent.getText()+strPara);
int nTemp1 = nMax/((int)Math.pow(10,nLength - nOffsetPara -1));
int nTemp2 = nMin/((int)Math.pow(10,nLength - nOffsetPara -1));
if(nValue>nTemp1 ||nValuenTemp1 || Integer.parseInt(textComponent.getText()+strPara)
private JTextComponent textComponent;
private int nLength = 10;
private String strType = new String(); // Store type
boolean bFlag = false;
private int nMin = 0;
private int nMax = 0;
private int nLimitLength = 0;
public controlLengthDocument(JTextComponent textComponentPara) {
textComponent = textComponentPara;
}
public controlLengthDocument(JTextComponent textComponentPara, int nLengthPara) {
textComponent = textComponentPara;
nLength = nLengthPara;
}
public controlLengthDocument(JTextComponent textComponentPara, int nLengthPara, String strTypePara) {
textComponent = textComponentPara;
nLength = nLengthPara;
strType = strTypePara;
}
public controlLengthDocument(JTextComponent textComponentPara, int nLengthPara, String strTypePara, int nMinPara, int nMaxPara) {
textComponent = textComponentPara;
nLength = nLengthPara;
strType = strTypePara;
nMin = nMinPara;
nMax = nMaxPara;
bFlag = true;
nLimitLength = Integer.toString(nMin).length();
}
public void insertString(int nOffsetPara, String strPara,AttributeSet attributeSetPara)
throws BadLocationException {
if (strType.equals("int")) {
try{
Integer.parseInt(strPara);
}catch(Exception ex){
return;
}
}
if (nOffsetPara >= (nLength - nLimitLength)) {
if(bFlag) {
int nValue = Integer.parseInt(textComponent.getText()+strPara);
int nTemp1 = nMax/((int)Math.pow(10,nLength - nOffsetPara -1));
int nTemp2 = nMin/((int)Math.pow(10,nLength - nOffsetPara -1));
if(nValue>nTemp1 ||nValuenTemp1 || Integer.parseInt(textComponent.getText()+strPara)