package com.sunwin.metro.utils;

import java.io.UnsupportedEncodingException;
import java.text.DecimalFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 字符串工具类
 *
 * @author tanghui
 * @date 2019/12/4 17:52
 */
public class StringUtils {


    /**
     * 判断object是否为空，或者转换成字符串（ String.valueOf(object)）是否为空字符串
     *
     * @param object Object对象
     * @author tanghui
     * @date 2019-08-28 14:52
     **/
    public static boolean isNullOrEmpty(Object object) {
        return object == null || String.valueOf(object).trim().length() == 0;
    }

    /**
     * 判断集合是否是null值或没有元素
     *
     * @param collection 继承collection的类
     * @return boolean
     */
    public static boolean isNullOrEmpty(Collection<?> collection) {
        return collection == null || collection.size() == 0;
    }


    /**
     * DecimalFormat转换最简便
     */
    public static Double m2(Double input) {
        DecimalFormat df = new DecimalFormat("#.00");
        return Double.parseDouble(df.format(input));
    }


    public static void main(String[] args) {
    }


}
