1、判断对象是否为空
public static boolean isEmpty(Object o){
if(o==null)
return true;
if(o instanceof String){
String str=(String) o;
if("".equals(str))
return true;
}
return false;
}
2、得到当前时间
public static Timestamp getCurrentTimestamp() {
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date = sdf.format(new Date());
return Timestamp.valueOf(date);
}
3、首字母大写
public static String capitalizeStr(String str){
String result=Character.toUpperCase(str.charAt(0))+str.substring(1, str.length());
return result;
}
4、时间格式化
public static String getYYYYMMDDHHmmss(Date date){
if(date==null)
return "";
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String str = sdf.format(date);
return str;
}