/**
 *  ClassName: DataValidateUtil.java
 *  created on Jul 10, 2009
 *  Copyrights 2009 www.tjicast.com All rights reserved.
 *  site: http://www.tjitcast.com
 *  email: tjhr@csdn.net
 *  phone: 022-83726777,89721888
 */
package com.javacrazyer.common;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.Map;
/**
 * 对一些常用数据进行操作的工具类
 * 
 */
public class DataOptUtil {
	
	
	/** 日期长格式 */
	public static final String DATE_PATTERN_LONG = "yyyy-MM-dd HH:mm:ss";
	/** 日期格式 */
	public static final String DATE_PATTERN = "yyyy-MM-dd";
	
	public static boolean isNotNull(String str){
		if(null != str && !"".equals(str)){
			return true;
		}else{
			return false;
		}
	}
	
	public static int parseInt(String str){
		if(isNotNull(str)){
			return Integer.parseInt(str);
		}else{
			throw new RuntimeException("字符串为空,不能转换成数字");
		}
	}
	
	public static Date parseDate(String str, String pattern){
		SimpleDateFormat sdf = new SimpleDateFormat(pattern);
		Date date = null;
		if(isNotNull(str)){
			try {
				date = sdf.parse(str);
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}else{
			throw new RuntimeException("字符串为空,不能转换成日期");
		}
		return date;
	}
	
	public static Date parseDate(String str){
		return parseDate(str, DataOptUtil.DATE_PATTERN);
	}
	
	public static Date parseLongDate(String str){
		return parseDate(str, DataOptUtil.DATE_PATTERN_LONG);
	}
	
	public static String date2String(Date date, String pattern){
		SimpleDateFormat sdf = new SimpleDateFormat(pattern);
		return sdf.format(date);
	}
	
	public static String Date2String(Date date){
		return date2String(date, DataOptUtil.DATE_PATTERN);
	}
	
	public static String Date2LongString(Date date){
		return date2String(date, DataOptUtil.DATE_PATTERN_LONG);
	}
	
	public static int getSize(Collection<?> coll){
		int size = coll == null ? 0 : coll.size();
		return size;
	}
	
	public static int getSize(Map<?,?> map){
		int size = map == null ? 0 : map.size();
		return size;
	}
	
	public static int getLength(Object[] obj){
		int length = 0;
		length = obj == null ? 0 : obj.length;
		return length;
	}
}
 最近下载更多
最近下载更多
                
                hanl     LV12
                2023年5月23日
            
            
        
                明123456     LV11
                2021年5月27日
            
            
        
                wallioms65     LV5
                2020年9月8日
            
            
        
                HomeInGuanglunshan     LV10
                2020年8月12日
            
            
        
                kiki777     LV1
                2020年5月27日
            
            
        
                不打不相识     LV12
                2020年5月26日
            
            
        
                13940562934     LV22
                2020年5月16日
            
            
        
                aisc1314     LV14
                2020年3月25日
            
            
        
                hehe264     LV20
                2020年2月6日
            
            
        
                拖拉机猿人     LV1
                2019年12月5日
            
            
         最近浏览更多
最近浏览更多
                
                renjunyou     LV10
                6月2日
            
            
        
                try8023     LV19
                2024年3月27日
            
            
        
                Liang朝伟     LV1
                2024年1月6日
            
            
        
                lvhongquan     LV11
                2023年12月30日
            
            
        
                asddwh     LV13
                2023年12月29日
            
            
        
                uni-code_0123     LV1
                2023年11月11日
            
            
        
                Y123yuan     LV3
                2023年6月30日
            
            
        
                hanl     LV12
                2023年5月23日
            
            
        
                微信网友_6206233028890624     LV2
                2022年11月10日
            
            
        
                小丶无奈     LV10
                2022年6月15日
            
            
        
 
                 
                 
                