1. Get the current time of the system:
Because there are many operations with a large amount of data, it is necessary to record the usage time. I usually write something myself. After all, I have been browsing the blog for so long. I have never posted an article.
Date sysTime = new Date(); SimpleDateFormat sdf = new SimpleDateFormat('yyyy-MM-dd HH:mm:ss'); sdf.format (sysTime);
Remember one thing. Most of the time is recorded at the beginning and end of the code. So when you need a new date at the beginning of the recording time and a new one at the end
2. Randomly output a string based on the given string
public static String getRandomString(int length){ String str = "1234567890qwertyuiopasdfghjklzxcvbnmWGJB"; Random random = new Random(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < length; i++){ int number = random.nextInt(length); sb.append(str.charAt(number)); } return sb.toString(); }