Pattern p=Pattern.compile("(\\d{4})-(\\d{1,2})-(\\d{1,2})");//从时间字符串中获取年,月,日的正则表达式
if (StringUtils.isBlank(StrTime)) {
Matcher m=p.matcher(endTime);
if(m.find()){
System.out.println("日期:"+m.group());
System.out.println("年:"+m.group(1));
System.out.println("月:"+m.group(2));
System.out.println("日:"+m.group(3));
}
}