easyui DataGrid 工具类之 Utils class
import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.gsoft.cos.core.util.Assert;
import com.gsoft.cos.core.util.BeanUtils;
/**
* @author 作者 E-mail:
* @version 创建时间:2015年9月26日 下午7:30:24
* 类说明
*/
public class GgczUtil {
public String getDateString(Date date,String str){
String dateStr=new SimpleDateFormat(str).format(date);
return dateStr;
}
public Date getDate(Date date,String str) throws ParseException{
SimpleDateFormat sdf=new SimpleDateFormat(str);
Date newdate = (Date) sdf.parse(date.toString());
return newdate;
}
public Date getDate(String date,String str) throws ParseException{
SimpleDateFormat sdf=new SimpleDateFormat(str);
Date newdate = (Date) sdf.parse(date);
return newdate;
}
public String getDateToString(String date,String str) throws ParseException{
SimpleDateFormat dateFormat = new SimpleDateFormat(str);
Date dateStr=null;
try {
dateStr = dateFormat.parse(date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return dateFormat.format(dateStr);
}
@SuppressWarnings({"unchecked", "rawtypes"})
public List< Map<String, Object>> listToMap(List<?> list) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException{
List<Map<String, Object>> lm=new ArrayList<Map<String, Object>>();
for (int i = 0; i < list.size(); i++) {
Map parameter = new HashMap<String, Object>();
parameter = BeanUtils.describe(list.get(i));
lm.add(parameter);
}
return lm;
}
public int daysBetween(Date early, Date late) {
java.util.Calendar calst = java.util.Calendar.getInstance();
java.util.Calendar caled = java.util.Calendar.getInstance();
calst.setTime(early);
caled.setTime(late);
//设置时间为0时
calst.set(java.util.Calendar.HOUR_OF_DAY, 0);
calst.set(java.util.Calendar.MINUTE, 0);
calst.set(java.util.Calendar.SECOND, 0);
caled.set(java.util.Calendar.HOUR_OF_DAY, 0);
caled.set(java.util.Calendar.MINUTE, 0);
caled.set(java.util.Calendar.SECOND, 0);
//得到两个日期相差的天数
int days = ((int) (caled.getTime().getTime() / 1000) - (int) (calst
.getTime().getTime() / 1000)) / 3600 / 24;
if(calst.getTime().getTime()<caled.getTime().getTime()){
days=-days;
}
return days;
}
public boolean isInteger(String str) {// 判断整型
return str.matches("^\\d+$$");
}
public boolean isNumber(String str) {// 判断整数或double
if(isInteger(str)||isDouble(str)){
return true;
}
return false;
}
public boolean isDouble(String str) {// 判断小数,与判断整型的区别在与d后面的小数点(红色)
return str.matches("\\d+\\.\\d+$");
}
public boolean isStartPointNubmer(String str) {// 判断小数点开头
return str.matches("\\.\\d+$");
}
public String getDoubleRound(String str){
if(Assert.isNotEmpty(str)){
return String.format("%.2f", Double.parseDouble(str));
}
return String.format("%.2f", Double.parseDouble("0.00"));
}
/**
* 根据数组符号获得符号间隔字符串
* @param args
* @param symbol
* @return
*/
public String getStringToSymbol(String[] args,String symbol){
String newSymbol=",";
if(Assert.isNotEmpty(symbol)){
newSymbol=symbol;
}
if(Assert.isNotEmpty(args)){
String str="";
for (String string : args) {
str+=string+newSymbol;
}
return str.substring(0,str.length()-1);
}
return "";
}
/**
* 根据数组符号获得符号间隔字符串
* @param args
* @param symbol
* @return
*/
public String getStringToSymbol(Integer[] args,String symbol){
String newSymbol=",";
if(Assert.isNotEmpty(symbol)){
newSymbol=symbol;
}
if(Assert.isNotEmpty(args)){
String str="";
for (Integer string : args) {
str+=string+newSymbol;
}
return str.substring(0,str.length()-1);
}
return "";
}
/**
* @author
* 分割list
* @param list
* @param pageSize
* @return
*/
public static <T> List<List<T>> splitList(List<T> list, int pageSize) {
List<List<T>> listArray = new ArrayList<List<T>>();
ArrayList<T> al = new ArrayList<T>();
for(T x : list){
al.add(x);
if (pageSize == al.size()){
listArray.add(al);
al = new ArrayList<T>();
}
}
if (0 != al.size())
listArray.add(al);
return listArray;
}
}
easyui DataGrid 工具类之 Utils class的更多相关文章
- easyui DataGrid 工具类之 WorkbookUtil class
/** * @Title: WorkbookUtil.java * @Description: excel工具类 * @date 2014年5月29日 上午10:36:42 * @version V1 ...
- easyui DataGrid 工具类之 TableUtil class
import java.lang.reflect.InvocationTargetException;import java.util.ArrayList;import java.util.HashM ...
- easyui DataGrid 工具类之 util js
var jq; var tab; var tabsIndex; /** ...
- easyui DataGrid 工具类之 后台生成列
@SuppressWarnings({ "rawtypes", "unchecked" }) public Map<String, Object&g ...
- easyui DataGrid 工具类之 列属性class
public class ColumnVO { /** * 列标题文本 */ private String title; /** * 列字段名称 */ pr ...
- 国际化的工具类ognl utils
package yycg.util; import java.io.Serializable;import java.text.MessageFormat;import java.util.Array ...
- JAVA中SpringMVC获取bean方法,在工具类(utils)注入service
有时候我们会出现无法用注解 @Autowired 注入bean的情况,这个时候可以 通过contextLoader获取 WebApplicationContext ctx = ContextLoade ...
- mongoDB工具类以及测试类【java】
java操作mongo工具类 package Utils; import com.mongodb.MongoClient; import com.mongodb.MongoCredential; im ...
- 工具类 ,无需再存localstorage
/** * 工具类 */var Utils = { /** * 获得查询参数 */ getQueryString: function(name) { var search = location.sea ...
随机推荐
- tomcat域名问题
首先可以确认,tomcat支持以下的配置: 1.同一个tomcat配置多个端口来发布不同的应用,配置多个<Service>即可; 2.同一个tomcat可以配置多个虚拟主机,以指定不同的域 ...
- Linux下一些有用的指令
1. 安装源代码包用到的configure 这用来定位安装位置. 用法: ./configure -prefix=<安装目录>, 前提是文件中有configure执行文件.
- php 执行的目录到新的 directory 目录中
chdir : 改变目录. dir : 目录类别类. closedir : 关闭目录 handle. opendir : 打开目录 handle. readdir : 读取目录 handle. rew ...
- Empire C:Basic 2
作为人与计算机沟通的媒介,C语言给我们呈现了:printf.scanf.以及缓冲区. 1.printf("%d",a) %d:d是decimal base(十进制)的开头字母,意思 ...
- 【iCore3 双核心板_ uC/OS-III】例程一:认识 uC/OS-III
实验指导书及代码包下载: http://pan.baidu.com/s/1i4FuMep iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...
- Apache Spark技术实战之7 -- CassandraRDD高并发数据读取实现剖析
未经本人同意,严禁转载,徽沪一郎. 概要 本文就 spark-cassandra-connector 的一些实现细节进行探讨,主要集中于如何快速将大量的数据从cassandra 中读取到本地内存或磁盘 ...
- fight
为啥用block copy. 从栈到拷贝到堆 循环引用,控制器引用block. block里面调用 self self引用控件,控件引用block,block里面引用self http://www. ...
- 【java基础学习】字符串
字符串 1. java内存区域(堆区.栈区.常量池) 2. String方法 获取长度 length(); 获取位置 indexOf(index); lastIndexOf(index) 获取子串 c ...
- web页面隐藏鼠标
Java web项目需求需要做一个在页面中,鼠标隐藏,来浏览页面,让客户不能点金页面 重要代码: $('*').css('cursor','none!important'); 示例: <styl ...
- Slip.js(移动端跟随手指滑动组件,零依赖)
Slip.js可用于移动端滑动banner,移动端整屏滑动等效果,个人觉得用于移动端滑动banner比较好,不会和iScroll.js起冲突,因为它不依赖任何其它的js库. Html: <!do ...