| | |
| | | public static String time_yyyyMMddHHmmss = "yyyy-MM-dd HH:mm:ss"; |
| | | public static String time_yyyyMMdd = "yyyy-MM-dd"; |
| | | public static String time_yyyyMM = "yyyy-MM"; |
| | | public static String time_yyyy_MM = "yyyy_MM"; |
| | | public static String time_yyyyMMdd_HH_mm_ss = "yyyy-MM-dd_HH_mm_ss"; |
| | | public static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | public static SimpleDateFormat sdfwithOutday = new SimpleDateFormat("yyyy_MM"); |
| | |
| | | |
| | | List<String> dateList = new ArrayList<>(); |
| | | LocalDate currentDate = startDate; |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern(ActionUtil.time_yyyyMM); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern(ActionUtil.time_yyyy_MM); |
| | | while (!currentDate.isAfter(endDate)) { |
| | | String formattedDate = currentDate.format(formatter); |
| | | dateList.add(formattedDate); |
| | |
| | | } |
| | | return dateList; |
| | | } |
| | | // 匹配 "_" 后跟一个字母(小写或大写) |
| | | public static String toCamelCase(String input) { |
| | | // 匹配 "_" 后跟一个字母(小写或大写) |
| | | Pattern pattern = Pattern.compile("_(\\w)"); |
| | | Matcher matcher = pattern.matcher(input); |
| | | StringBuffer result = new StringBuffer(); |
| | | |
| | | while (matcher.find()) { |
| | | // 将匹配到的字母转为大写,并替换掉前面的下划线 |
| | | matcher.appendReplacement(result, matcher.group(1).toUpperCase()); |
| | | } |
| | | matcher.appendTail(result); |
| | | |
| | | return result.toString(); |
| | | } |
| | | |
| | | public static void main(String[] args) throws ParseException { |
| | | List<String> dateList =getDateListBetweenDates(ActionUtil.sdf.parse("2025-01-01 00:00:00"),new Date()); |
| | | /*List<String> dateList =getDateListBetweenDates(ActionUtil.sdf.parse("2025-01-01 00:00:00"),new Date()); |
| | | for (String date : dateList) { |
| | | System.out.println(date); |
| | | } |
| | | }*/ |
| | | System.out.println(toCamelCase("user_name_and_age")); |
| | | } |
| | | } |