📄 commutil.java
字号:
package net.meybo.util;
import java.io.File;
public abstract class CommUtil {
private static final java.text.SimpleDateFormat dateFormat=new java.text.SimpleDateFormat("yyyy-MM-dd");
public static java.text.SimpleDateFormat getDateFormat() {
return dateFormat;
}
public static String format(java.util.Date v)
{
return dateFormat.format(v);
}
public static java.util.Date formatDate(String s)
{
java.util.Date d=null;
try{
d=dateFormat.parse(s);
}
catch(Exception e)
{
}
return d;
}
public static String null2String(Object s)
{
return s==null?"":s.toString();
}
public static String null2String(String s)
{
return s==null?"":s.toString();
}
public static int null2Int(String s)
{
return com.easyjf.util.CommUtil.null2Int(s);
}
public static String round(double inNumber,int param){
String format="#.";
for(int i=0;i<param;i++){
format=format.concat("#");
}
//去掉多余小数点
if(param==0){
format=format.substring(0,format.toString().length()-1);
}
java.text.DecimalFormat df =new java.text.DecimalFormat(format);
return df.format(inNumber);
}
public static String getOnlyID(){
return com.easyjf.util.CommUtil.getOnlyID();
}
public static String getNewFileID(String path, String ext) {
String id = "";
try {
boolean flag = true;
do {
id = CommUtil.getOnlyID();
File file = new File(path + id + ext);
if (!file.exists())
flag = false;
} while (flag == true);
} catch (Exception ex) {
ex.printStackTrace();
}
return id;
}
/**
* 显示页码
* @param currentPage
* @param pages
* @return
*/
public static String showPageHtml(int currentPage,int pages)
{
String s="";
if(currentPage>1)
{
s+="<a href=# onclick='GoPage(1)'>未页</a> ";
s+="<a href=# onclick='GoPage("+(currentPage+1)+")'>下一页</a> ";
}
if(currentPage<pages)
{
s+="<a href=# onclick='GoPage("+pages+")'>首页</a> ";
s+="<a href=# onclick='GoPage("+(currentPage-1)+")'>上一页</a> ";
}
int beginPage=currentPage-3<1?1:currentPage-3;
if(beginPage<pages){
s+="第";
for(int i=beginPage,j=0;i<pages&&j<6;i++,j++)
{
s+="<a href=# onclick='GoPage("+i+")'>"+i+"</a> ";
}
s+="页";
}
s+=" 转到<input type=text size=2>页";
return s;
}
public static String toChinese(String strvalue)
{
return com.easyjf.util.CommUtil.toChinese(strvalue);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -