package com.iamberry.wechat.tools;

import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ToolsUtils {
	
	public static boolean isNotEmpty(Object obj){
		if(null == obj){
			return false;
		} else if(obj instanceof String){
			if("".equals(((String)obj).trim()) || "null".equals(((String)obj).trim())){
				return false;
			}
		}
		return true;
	}
	
	public static String dateToString(Date date){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		return sdf.format(date);
	}
	
	public static String dateToStringFull(Date date){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return sdf.format(date);
	}
	
	public static Date stringToDateFull(String datestr) throws ParseException{
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return sdf.parse(datestr);
	}
	
	public static Double Double2point(Double d){
		if(d != null){
			DecimalFormat df=new DecimalFormat(".##");
			String st=df.format(d);
			d = Double.parseDouble(st);
		}else{
			d = 0.00;
		}
		return d;
	}
}
