【发布时间】:2019-05-20 08:48:57
【问题描述】:
我有一个类似"/etc/opt/eset/esets/license/esets_abd9c6.lic: ESET File Security, 2019-07-29 00:00:00, Mynet" 的字符串变量,我需要从该字段中捕获日期值,但我无法弄清楚。
String string = "/etc/opt/eset/esets/license/esets_abd9c6.lic: ESET File Security, 2019-07-29 00:00:00, Mynet";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Pattern p = Pattern.compile("");
Matcher m = p.matcher(input);
Date tempDate = null;
if(m.find())
{
tempDate = format.parse(m.group());
}
System.out.println("" + tempDate);
是否有任何正则表达式模式可以从字符串变量中捕获日期值?
【问题讨论】:
-
String 会是一样的吗?