You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			77 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Java
		
	
			
		
		
	
	
			77 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Java
		
	
| package com.glxp.api.util;
 | |
| 
 | |
| import java.util.*;
 | |
| 
 | |
| public class CustomUtil {
 | |
| 
 | |
|     public static String getUUId() {
 | |
|         UUID uuid = UUID.randomUUID();
 | |
|         return uuid.toString().replace("-", "");
 | |
|     }
 | |
| 
 | |
|     //随机生成ID
 | |
|     public static String getId() {
 | |
|         String id = System.currentTimeMillis() + "";
 | |
|         int number = new Random().nextInt(90) + 10;
 | |
|         id = id + number;
 | |
|         return id.substring(1);
 | |
|     }
 | |
| 
 | |
| 
 | |
|     public static <T> List<List<T>> splitList(List<T> list, int len) {
 | |
| 
 | |
|         if (list == null || list.isEmpty() || len < 1) {
 | |
|             return Collections.emptyList();
 | |
|         }
 | |
| 
 | |
|         List<List<T>> result = new ArrayList<>();
 | |
| 
 | |
|         int size = list.size();
 | |
|         int count = (size + len - 1) / len;
 | |
| 
 | |
|         for (int i = 0; i < count; i++) {
 | |
|             List<T> subList = list.subList(i * len, ((i + 1) * len > size ? size : len * (i + 1)));
 | |
|             result.add(subList);
 | |
|         }
 | |
| 
 | |
|         return result;
 | |
|     }
 | |
| 
 | |
| 
 | |
|     //随机生成往来单位ID
 | |
|     public static String getUnitId() {
 | |
|         String id = System.currentTimeMillis() + "";
 | |
|         int number = new Random().nextInt(90) + 10;
 | |
|         id = id + number;
 | |
|         return "HZ" + id.substring(4);
 | |
|     }
 | |
| 
 | |
|     public static boolean isEmpty(List data) {
 | |
|         if (data == null || data.isEmpty()) {
 | |
|             return true;
 | |
|         }
 | |
|         return false;
 | |
|     }
 | |
| 
 | |
|     public static boolean isNotEmpty(List data) {
 | |
|         if (data != null && !data.isEmpty()) {
 | |
|             return true;
 | |
|         }
 | |
|         return false;
 | |
|     }
 | |
| 
 | |
|     //生成当前时间字符串
 | |
|     public static   String getDate(){
 | |
|         Calendar ca = Calendar.getInstance();
 | |
|         String year = String.valueOf(ca.get(Calendar.YEAR));//获取年份
 | |
|         String month=String.valueOf(ca.get(Calendar.MONTH));//获取月份
 | |
|         String day=String.valueOf(ca.get(Calendar.DATE));//获取日
 | |
|         String minute=String.valueOf(ca.get(Calendar.MINUTE));//分
 | |
|         String hour=String.valueOf(ca.get(Calendar.HOUR));//小时
 | |
|         String second=String.valueOf(ca.get(Calendar.SECOND));//秒
 | |
|         return  year+month+day+hour+minute+second;
 | |
|     }
 | |
| 
 | |
| 
 | |
| }
 |