📄 checkvalue.java
字号:
package com.suninformation.tools;
import java.util.Calendar;
import java.sql.Date;
import java.security.*;
/**
* 数据类型检查
*
* <p>Title: SunInformation's toolkit system</p>
*
* <p>Description: 系统常用工具包</p>
*
* <p>Copyright: Copyright (c) 2005-03-17</p>
*
* <p>Company: 梦想软件开发工作室</p>
*
* @author 刘镇
* @version 1.0
*/
public class CheckValue {
/**
* 是否为数值型
*
* @param numString String
* @return boolean
*/
public static boolean isNumber(String numString) {
boolean is = false;
try {
Integer.parseInt(numString);
is = true;
}
catch (NumberFormatException e) {
}
return is;
}
public static Date isSQLDate(int year, int month, int day) {
Date sqlDate = null;
if ( (year < 1930 || year > 2005) || (month < 1 || month > 12) ||
(day < 1 || day > 31)) {
}
else if (year != -1 && month != -1 && day != -1) {
try {
Calendar mDate = Calendar.getInstance();
mDate.set(year, month - 1, day);
sqlDate = new Date(mDate.getTimeInMillis());
}
catch (Exception e) {
return null;
}
}
return sqlDate;
}
//HTML特殊字符转换
public static String HtmlSpecialChars(String str) {
if (str == null || str.equals("")) {
return str;
}
StringBuffer temp = new StringBuffer();
int i = 0;
while (i < str.length()) {
//将\n转换成<br>
if (str.charAt(i) == '\n') {
temp = temp.append("<br>");
}
//将空格转换成
else if (str.charAt(i) == ' ') {
temp = temp.append(" ");
}
//将<转换成<
else if (str.charAt(i) == '<') {
temp = temp.append("<");
}
//将>转换成>
else if (str.charAt(i) == '>') {
temp = temp.append(">");
}
else {
temp = temp.append(str.substring(i, i + 1));
}
i++;
}
String okstring = temp.toString();
return okstring;
}
//MD5加密
public static String md5(String x) {
try {
MessageDigest m = MessageDigest.getInstance("MD5");
m.update(x.getBytes("UTF8"));
byte s[] = m.digest();
String result = "";
for (int i = 0; i < s.length; i++) {
result += Integer.toHexString( (0x000000FF & s[i]) | 0xFFFFFF00).
substring(6);
}
return result;
}
catch (Exception e) {
return null;
}
}
public static String showClassMessage(String str) {
String temp = HtmlSpecialChars(str);
temp = temp.replaceAll("//1//","<img src='Images/Pic/1.gif'>");
temp = temp.replaceAll("//2//","<img src='Images/Pic/2.gif'>");
temp = temp.replaceAll("//3//","<img src='Images/Pic/3.gif'>");
temp = temp.replaceAll("//4//","<img src='Images/Pic/4.gif'>");
temp = temp.replaceAll("//5//","<img src='Images/Pic/5.gif'>");
temp = temp.replaceAll("//6//","<img src='Images/Pic/6.gif'>");
temp = temp.replaceAll("//7//","<img src='Images/Pic/7.gif'>");
temp = temp.replaceAll("//8//","<img src='Images/Pic/8.gif'>");
temp = temp.replaceAll("//9//","<img src='Images/Pic/9.gif'>");
temp = temp.replaceAll("//10//","<img src='Images/Pic/10.gif'>");
temp = temp.replaceAll("//11//","<img src='Images/Pic/11.gif'>");
temp = temp.replaceAll("//12//","<img src='Images/Pic/12.gif'>");
temp = temp.replaceAll("//13//","<img src='Images/Pic/13.gif'>");
temp = temp.replaceAll("//14//","<img src='Images/Pic/14.gif'>");
temp = temp.replaceAll("//15//","<img src='Images/Pic/15.gif'>");
temp = temp.replaceAll("//16//","<img src='Images/Pic/16.gif'>");
temp = temp.replaceAll("//17//","<img src='Images/Pic/17.gif'>");
temp = temp.replaceAll("//18//","<img src='Images/Pic/18.gif'>");
temp = temp.replaceAll("//19//","<img src='Images/Pic/19.gif'>");
temp = temp.replaceAll("//20//","<img src='Images/Pic/20.gif'>");
temp = temp.replaceAll("//21//","<img src='Images/Pic/21.gif'>");
temp = temp.replaceAll("//22//","<img src='Images/Pic/22.gif'>");
temp = temp.replaceAll("//23//","<img src='Images/Pic/23.gif'>");
temp = temp.replaceAll("//24//","<img src='Images/Pic/24.gif'>");
temp = temp.replaceAll("//25//","<img src='Images/Pic/25.gif'>");
temp = temp.replaceAll("//26//","<img src='Images/Pic/26.gif'>");
temp = temp.replaceAll("//27//","<img src='Images/Pic/27.gif'>");
temp = temp.replaceAll("//28//","<img src='Images/Pic/28.gif'>");
temp = temp.replaceAll("//29//","<img src='Images/Pic/29.gif'>");
temp = temp.replaceAll("//30//","<img src='Images/Pic/30.gif'>");
temp = temp.replaceAll("//31//","<img src='Images/Pic/31.gif'>");
temp = temp.replaceAll("//32//","<img src='Images/Pic/32.gif'>");
temp = temp.replaceAll("//33//","<img src='Images/Pic/33.gif'>");
temp = temp.replaceAll("//34//","<img src='Images/Pic/34.gif'>");
temp = temp.replaceAll("//35//","<img src='Images/Pic/35.gif'>");
temp = temp.replaceAll("//36//","<img src='Images/Pic/36.gif'>");
temp = temp.replaceAll("//37//","<img src='Images/Pic/37.gif'>");
temp = temp.replaceAll("//38//","<img src='Images/Pic/38.gif'>");
temp = temp.replaceAll("//39//","<img src='Images/Pic/39.gif'>");
temp = temp.replaceAll("//40//","<img src='Images/Pic/40.gif'>");
temp = temp.replaceAll("//41//","<img src='Images/Pic/41.gif'>");
temp = temp.replaceAll("//42//","<img src='Images/Pic/42.gif'>");
temp = temp.replaceAll("//43//","<img src='Images/Pic/43.gif'>");
temp = temp.replaceAll("//44//","<img src='Images/Pic/44.gif'>");
temp = temp.replaceAll("//45//","<img src='Images/Pic/45.gif'>");
temp = temp.replaceAll("//46//","<img src='Images/Pic/46.gif'>");
temp = temp.replaceAll("//47//","<img src='Images/Pic/47.gif'>");
temp = temp.replaceAll("//48//","<img src='Images/Pic/48.gif'>");
temp = temp.replaceAll("//49//","<img src='Images/Pic/49.gif'>");
temp = temp.replaceAll("//50//","<img src='Images/Pic/50.gif'>");
temp = temp.replaceAll("//51//","<img src='Images/Pic/51.gif'>");
temp = temp.replaceAll("//52//","<img src='Images/Pic/52.gif'>");
temp = temp.replaceAll("//53//","<img src='Images/Pic/53.gif'>");
temp = temp.replaceAll("//54//","<img src='Images/Pic/54.gif'>");
temp = temp.replaceAll("//55//","<img src='Images/Pic/55.gif'>");
temp = temp.replaceAll("//56//","<img src='Images/Pic/56.gif'>");
temp = temp.replaceAll("//57//","<img src='Images/Pic/57.gif'>");
temp = temp.replaceAll("//58//","<img src='Images/Pic/58.gif'>");
temp = temp.replaceAll("//59//","<img src='Images/Pic/59.gif'>");
temp = temp.replaceAll("//60//","<img src='Images/Pic/60.gif'>");
temp = temp.replaceAll("//61//","<img src='Images/Pic/61.gif'>");
temp = temp.replaceAll("//62//","<img src='Images/Pic/62.gif'>");
temp = temp.replaceAll("//63//","<img src='Images/Pic/63.gif'>");
temp = temp.replaceAll("//64//","<img src='Images/Pic/64.gif'>");
return temp;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -