Commit ceb8f918 by 东州 翁

改良正则表达式

parent 73e3c637
...@@ -16,7 +16,6 @@ import java.util.regex.Pattern; ...@@ -16,7 +16,6 @@ import java.util.regex.Pattern;
import cn.timer.api.dto.yggl.YgbintuDto; import cn.timer.api.dto.yggl.YgbintuDto;
import lombok.Getter; import lombok.Getter;
import net.sf.ehcache.search.expression.Between;
/** /**
* @date 2020年3月23日 * @date 2020年3月23日
...@@ -113,31 +112,32 @@ public interface YgEnumInterface { ...@@ -113,31 +112,32 @@ public interface YgEnumInterface {
} }
public static String tranTime(String index) { public static String tranTime(String index) {
DateFormat zhenFormat = new SimpleDateFormat(ZHEN.name); //String str ="2013/11/12";
String result = zhenFormat.format(new Date()); String p = "年|月|日|号|时|/|//-";
if (index == null || index.length() == 0) return result; String result = index.replaceAll(p, "-");
Pattern pattern = Pattern.compile("^[0-9]{8}$"); String p2 = "-$";
if (pattern.matcher(index).matches()) { String result2 = result.replaceAll(p2, "");
result = index.substring(0, 4) + "-" + index.substring(4, 6) + "-" + index.substring(6, 8); return result2;
return result;
}
String s = index.replaceAll("([1-9]+[0-9]*|0)(\\.[\\d]+)?", "");
for (rzTime item : rzTime.values()) {
if (s.indexOf(item.type) != -1) {
DateFormat dateFormat = new SimpleDateFormat(item.name);
try {
result = new SimpleDateFormat(ZHEN.name).format(dateFormat.parse(index));
return result;
} catch (ParseException e) {
e.printStackTrace();
return result;
}
}
}
return result;
} }
/*
* public static String tranTime(String index) { DateFormat zhenFormat = new
* SimpleDateFormat(ZHEN.name); String result = zhenFormat.format(new Date());
* if (index == null || index.length() == 0) return result; Pattern pattern =
* Pattern.compile("^[0-9]{8}$"); if (pattern.matcher(index).matches()) { result
* = index.substring(0, 4) + "-" + index.substring(4, 6) + "-" +
* index.substring(6, 8); return result; } String s =
* index.replaceAll("([1-9]+[0-9]*|0)(\\.[\\d]+)?", ""); for (rzTime item :
* rzTime.values()) { if (s.indexOf(item.type) != -1) { DateFormat dateFormat =
* new SimpleDateFormat(item.name); try { result = new
* SimpleDateFormat(ZHEN.name).format(dateFormat.parse(index)); return result; }
* catch (ParseException e) { e.printStackTrace(); return result; } } } return
* result; }
*/
public static String tranTime2(String result) { public static String tranTime2(String result) {
String isYear ="^(?:(?!0000)[0-9]{4} -(?:(?:0[1-9]|1[0-2]) -(?:0[1-9]|1[0-9]|2[0-8]) |(?:0[13-9]|1[0-2]) -(?:29|30) |(?:0[13578]|1[02]) -31 )|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00) -02 -29 )$"; String isYear ="^(?:(?!0000)[0-9]{4} -(?:(?:0[1-9]|1[0-2]) -(?:0[1-9]|1[0-9]|2[0-8]) |(?:0[13-9]|1[0-2]) -(?:29|30) |(?:0[13578]|1[02]) -31 )|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00) -02 -29 )$";
Pattern pattern = Pattern.compile(isYear); Pattern pattern = Pattern.compile(isYear);
......
...@@ -1513,7 +1513,6 @@ public class YgglController { ...@@ -1513,7 +1513,6 @@ public class YgglController {
Integer type = ygjgDto.getType(); Integer type = ygjgDto.getType();
Integer upId = ygjgDto.getJgid(); Integer upId = ygjgDto.getJgid();
List<YgjgDto> maps = new ArrayList<YgjgDto>(); List<YgjgDto> maps = new ArrayList<YgjgDto>();
if (type == 1) { // 省份 if (type == 1) { // 省份
List<YgProDto> list = new LambdaQueryChainWrapper<YgProDto>(ygProDtoMapper) List<YgProDto> list = new LambdaQueryChainWrapper<YgProDto>(ygProDtoMapper)
.select(YgProDto::getId, YgProDto::getProvince, YgProDto::getName).orderByAsc(YgProDto::getProvince) .select(YgProDto::getId, YgProDto::getProvince, YgProDto::getName).orderByAsc(YgProDto::getProvince)
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
package cn.timer.api.dto.yggl; package cn.timer.api.dto.yggl;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Transient; import javax.persistence.Transient;
...@@ -26,7 +28,7 @@ import lombok.NoArgsConstructor; ...@@ -26,7 +28,7 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class YgjgDto implements Serializable { public class YgjgDto implements Serializable{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -44,4 +46,5 @@ public class YgjgDto implements Serializable { ...@@ -44,4 +46,5 @@ public class YgjgDto implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private String jgname; private String jgname;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment