From 6d313a4a6f9f9d7ea65ec50ab0d4491e595edb97 Mon Sep 17 00:00:00 2001 From: admin <15939171744@163.com> Date: 星期二, 15 十月 2024 09:47:26 +0800 Subject: [PATCH] -打印bug修改 --- jcdm-main/src/main/java/com/jcdm/main/plcserver/util/TimeUtil.java | 30 +++++++++++++++++++++++++++++- 1 files changed, 29 insertions(+), 1 deletions(-) diff --git a/jcdm-main/src/main/java/com/jcdm/main/plcserver/util/TimeUtil.java b/jcdm-main/src/main/java/com/jcdm/main/plcserver/util/TimeUtil.java index 1f37a20..97269cc 100644 --- a/jcdm-main/src/main/java/com/jcdm/main/plcserver/util/TimeUtil.java +++ b/jcdm-main/src/main/java/com/jcdm/main/plcserver/util/TimeUtil.java @@ -7,13 +7,41 @@ import java.util.Date; import java.util.Locale; import java.util.TimeZone; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class TimeUtil { public static void main(String[] args) { String dateString = "Tue May 14 18:25:18 CST 2024"; // System.out.println(test(dateString)); +// String str = "OP330"; +// System.out.println(str.substring(0,5)); +// String tightenData = "[9.077463,12.0,OK,OK]"; +// tightenData = tightenData.replace("[", "").replace("]", "").replace(" ", ""); +// String[] tightenDataParts = tightenData.split(","); +// for (int i = 0; i < tightenDataParts.length; i++) { +// System.out.println(tightenDataParts[i]); +// } + String originalString = "[3.6,7.8,OK,OK]"; + String modifiedString = originalString.replaceFirst("OK", "NG"); + System.out.println(modifiedString); // 杈撳嚭: [3.6,7.8,NG,OK] +// System.out.println(isNumberInRange(7.7, 7.5, 8.5)); +// System.out.println(test( stringProcessing("DateTime{utcTime=133601559184960000, javaDate=Tue May 14 18:25:18 CST 2024}"))); + } - System.out.println(test( stringProcessing("DateTime{utcTime=133601559184960000, javaDate=Tue May 14 18:25:18 CST 2024}"))); + public static String replaceNumber(String input) { + String regex = ",(\\d+),"; + String replacement = ",NG,"; + + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(input); + + return matcher.replaceAll(replacement); + } + + // 妫�鏌ヤ竴涓暟鏄惁鍦ㄤ袱涓暟瀹氫箟鐨勫尯闂村唴锛堜笉鍖呭惈杈圭晫锛� + public static boolean isNumberInRange(Double number, Double start, Double end) { + return number >= start && number <= end; } public static String stringProcessing(String dateTimeStr){ -- Gitblit v1.9.3