|
@@ -432,18 +432,58 @@ public class HandleDataController extends BaseController
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
- File file = new File("C:\\Users\\10109\\Desktop\\新程序\\历史数据");
|
|
|
|
- if(file.isDirectory()){
|
|
|
|
- for (File listFile : file.listFiles()) {
|
|
|
|
-// System.out.println(listFile.getName());
|
|
|
|
- ExcelReader reader = ExcelUtil.getReader(listFile);
|
|
|
|
- List<List<Object>> readAll = reader.read();
|
|
|
|
- for (int i = 3; i < 10; i++) {
|
|
|
|
- System.out.println(readAll.get(i));
|
|
|
|
- }
|
|
|
|
- System.out.println("------------------");
|
|
|
|
|
|
+// File file = new File("C:\\Users\\10109\\Desktop\\新程序\\历史数据");
|
|
|
|
+// if(file.isDirectory()){
|
|
|
|
+// for (File listFile : file.listFiles()) {
|
|
|
|
+//// System.out.println(listFile.getName());
|
|
|
|
+// ExcelReader reader = ExcelUtil.getReader(listFile);
|
|
|
|
+// List<List<Object>> readAll = reader.read();
|
|
|
|
+// for (int i = 3; i < 10; i++) {
|
|
|
|
+// System.out.println(readAll.get(i));
|
|
|
|
+// }
|
|
|
|
+// System.out.println("------------------");
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String str = "2022/17/11 19:00:1";
|
|
|
|
+// String str = "2022/7/1";
|
|
|
|
+// String str = "0:0:1";
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
+ if(str.contains(" ")){//包含空格 就是年月日时分秒了
|
|
|
|
+ String[] split = str.split(" ");
|
|
|
|
+ addBeforeZero(sb, split[0], "/");
|
|
|
|
+ sb.append(" ");
|
|
|
|
+ addBeforeZero(sb, split[1], ":");
|
|
|
|
+ }else{
|
|
|
|
+ if(str.contains("/")){//年月日
|
|
|
|
+ addBeforeZero(sb, str, "/");
|
|
|
|
+ }else if(str.contains(":")){//时分秒
|
|
|
|
+ addBeforeZero(sb, str, ":");
|
|
|
|
+ }else {
|
|
|
|
+ sb.append(str);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ System.out.println(sb.toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public static StringBuilder addBeforeZero(StringBuilder sb, String str, String tag){
|
|
|
|
+ String[] split = str.split(tag);
|
|
|
|
+ int length = split.length;
|
|
|
|
+ for (int i = 0; i < length; i++) {
|
|
|
|
+ String value = split[i];
|
|
|
|
+ Integer intValue = Integer.parseInt(value);
|
|
|
|
+ if(intValue < 10 && value.length() == 1){////防止有正确的情况 额外再补充字符串
|
|
|
|
+ sb.append(0).append(value);
|
|
|
|
+ }else{
|
|
|
|
+ sb.append(value);
|
|
|
|
+ }
|
|
|
|
+ if(i < length-1){
|
|
|
|
+ sb.append(tag);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ return sb;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|