这段代码是一个静态方法,用于将一个字符串类型的日期转换为Date类型的日期。它接收两个参数:datestring表示需要转换的日期字符串,pattern表示日期字符串的格式,例如"yyyy-MM-dd"。如果传入的日期字符串和格式都不为空,方法会使用SimpleDateFormat解析日期,否则返回null。如果解析失败,也返回null。

public static Date parse2DateString datestring String pattern if !StringUtilsisBlankpattern && !StringUtilsisBlankdatestring SimpleDateFormat sdf = new SimpleDateFormatpattern;

原文地址: http://www.cveoy.top/t/topic/e13P 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录