ChenJiaHe
2021-02-24 cac339cb773b12721bc2c9886d5ab7ed9753f245
src/main/java/com/hx/util/DateUtil.java
@@ -216,8 +216,13 @@
     * @return
     * @throws Exception
     */
    public static Date parseString(String str) throws Exception {
        return Format_2.parse(str);
    public static Date parseString(String str) {
        try {
            return Format_2.parse(str);
        }catch (Exception e)
        {
            return null;
        }
    }
    /**
@@ -228,9 +233,14 @@
     * @return
     * @throws Exception
     */
    public static Date parseString(String str, String format) throws Exception {
    public static Date parseString(String str, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.parse(str);
        try{
            return sdf.parse(str);
        }catch (Exception e)
        {
            return null;
        }
    }
    /**字符串转成时间yyyy-MM-dd HH:mm:ss*/
@@ -435,4 +445,25 @@
        return str;
    }
    /**
     * 针对str格式的时间做转换 格式为"xx:xx"
     * @param time  传入的时间
     * @return  返回分钟如果10:25,则返回625
     */
    public static int getMinuteNum(String time){
        if(!StringUtils.isEmpty(time))
        {
            String[] arr = time.split(":");
            if(arr != null && arr.length == 2)
            {
                return Integer.parseInt(arr[0]) * 60 + Integer.parseInt(arr[1]);
            }
        }
        return 0;
    }
}