判断字符串是否为空

public static boolean IsEmpty(String str){
if (str == null){
return true;
}
if ("".equals(str)){
return true;
}
return false;
}

判断字符串str是否包含s1

public static boolean IsHas(String str,String s1){
if(IsEmpty(str)){
return false;
}
if(IsEmpty(s1)){
return false;
}
if(str.indexOf(s1) == -1){
return false;
}
return true;
}

判断list 是否为空

public static boolean IsEmptyList(List lt){
if (lt == null){
return true;
}
if (lt.size() == 0){
return true;
}
return false;
}

判断字符串是否相等

public static boolean Equals(String str1,String str2){
if(IsEmpty(str1)){
if(IsEmpty(str2)){
return true;
}else{
return false;
}
}
if (str1.equals(str2)){
return true;
}
return false;
}

俩个日期间隔的天数

    public static long MakeDateLength(String Date1, String Date2){
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
try{
Date d1 = df.parse(Date1);
Date d2 = df.parse(Date2);
long t1 = d1.getTime();
long t2 = d2.getTime();
long t = t1 - t2;
t /= 1000*60*60*24;
return t;
}
catch (ParseException e){
}
return 0;
}

通过给定日期推算新的日期,afterDay为经过的天数

public static String GetDateAfter(String date,int afterDay){
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
try{
Date d = df.parse(date);
long nTime = d.getTime();
long aTime = ((long) afterDay) * 24 * 60 * 60 * 1000;
d.setTime(nTime + aTime);
return df.format(d);
}
catch (ParseException e){
}
return "";
}

最新文章

  1. MVC 传值
  2. hdu 5749 Colmerauer
  3. Dive into python学习笔记
  4. /usr/bin/env: node: no such file or directory
  5. 页面中插入百度地图(使用百度地图API)
  6. [2014-08-24]为 Xamarin Studio 创建的 Asp.Net Mvc 项目配置 gitignore
  7. layui select使用问题
  8. 2.7 json 模块
  9. 利用Crosstool-ng制作交叉编译工具链
  10. react 的双向数据绑定
  11. JS 调试中常见的报错的解决办法
  12. [HAOI2010]最长公共子序列(LCS+dp计数)
  13. emoji表情softbank和unicode不兼容解决方案
  14. Linux服务安装配置总结
  15. luoguP4709 信息传递 置换 + 多项式exp
  16. Python中StringIO和BytesIO
  17. JSPatch动态更新APP
  18. 产品思维&技术思维&工程思维
  19. bzoj 3309 反演
  20. 第十六篇:初探IO复用

热门文章

  1. 如何解决结果由block返回情况下的同步问题(转)
  2. python函数默认参数坑
  3. [阅读笔记]Zhang Y. 3D Information Extraction Based on GPU.2010.
  4. Centos安装vsftp服务
  5. ant学习简单例子
  6. CSS的一些小技巧
  7. 初始JavaScript
  8. vue-新建项目出错情况分析
  9. ORBSLAM2与OPENCV3.1.0出错解决办法
  10. JQUERY MOBILE 中文API站 和 官方论坛