| | |
| | | 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){ |