|
@@ -2883,6 +2883,49 @@ public class CustomFunction {
|
|
|
}
|
|
|
|
|
|
*/
|
|
|
+ public static List<Object> toYear(List<Object> dateList){
|
|
|
+ return toDate(dateList,0);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static List<Object> toMonth(List<Object> dateList){
|
|
|
+ return toDate(dateList,1);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static List<Object> toDay(List<Object> dateList){
|
|
|
+ return toDate(dateList,2);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static List<Object> toDate(List<Object> dateList,int type){
|
|
|
+ List<Object> result = new ArrayList<>();
|
|
|
+ if(ListUtils.isNotEmpty(dateList)){
|
|
|
+ for (Object o : dateList) {
|
|
|
+ String d = StringUtils.handleNull(o);
|
|
|
+ if (StringUtils.isNotEmpty(d)) {
|
|
|
+ /* if (d.contains(",")) {
|
|
|
+ String[] arr = d.replaceAll("[\\[\\]\\s]+", "").split(",");
|
|
|
+ d = arr[arr.length - 1];
|
|
|
+ }*/
|
|
|
+ DateTime dt = new DateTime(d);
|
|
|
+ if(type==0) {
|
|
|
+ result.add(dt.year());
|
|
|
+ }else if(type==1) {
|
|
|
+ result.add(dt.month()+1);
|
|
|
+ }if(type==2) {
|
|
|
+ result.add(dt.dayOfMonth());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+/* public static void main(String[] args) {
|
|
|
+ List<Object> list = Arrays.asList("2024年07月2日","2024-07-2","2024.07.2");
|
|
|
+ toYear(list).forEach(System.out::println);
|
|
|
+ toMonth(list).forEach(System.out::println);
|
|
|
+ toDay(list).forEach(System.out::println);
|
|
|
+ }*/
|
|
|
|
|
|
|
|
|
|