Commit ceb8f918 by 东州 翁

改良正则表达式

parent 73e3c637
......@@ -16,7 +16,6 @@ import java.util.regex.Pattern;
import cn.timer.api.dto.yggl.YgbintuDto;
import lombok.Getter;
import net.sf.ehcache.search.expression.Between;
/**
* @date 2020年3月23日
......@@ -113,29 +112,30 @@ public interface YgEnumInterface {
}
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;
}
//String str ="2013/11/12";
String p = "年|月|日|号|时|/|//-";
String result = index.replaceAll(p, "-");
String p2 = "-$";
String result2 = result.replaceAll(p2, "");
return result2;
}
/*
* 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) {
......
......@@ -1513,7 +1513,6 @@ public class YgglController {
Integer type = ygjgDto.getType();
Integer upId = ygjgDto.getJgid();
List<YgjgDto> maps = new ArrayList<YgjgDto>();
if (type == 1) { // 省份
List<YgProDto> list = new LambdaQueryChainWrapper<YgProDto>(ygProDtoMapper)
.select(YgProDto::getId, YgProDto::getProvince, YgProDto::getName).orderByAsc(YgProDto::getProvince)
......
......@@ -6,6 +6,8 @@
package cn.timer.api.dto.yggl;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Transient;
......@@ -26,7 +28,7 @@ import lombok.NoArgsConstructor;
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class YgjgDto implements Serializable {
public class YgjgDto implements Serializable{
private static final long serialVersionUID = 1L;
......@@ -44,4 +46,5 @@ public class YgjgDto implements Serializable {
@TableField(exist = false)
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