|
|
@@ -0,0 +1,34 @@
|
|
|
+package com.uas.platform.b2b.core.util;
|
|
|
+
|
|
|
+import java.util.Random;
|
|
|
+import java.util.UUID;
|
|
|
+
|
|
|
+public class StringUtil {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 产生唯一字符串
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String uuid() {
|
|
|
+ return UUID.randomUUID().toString().replaceAll("\\-", "");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String substr(String str, int begin, int end) {
|
|
|
+ return str.substring(begin, Math.min(str.length(), end));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 随机数字
|
|
|
+ *
|
|
|
+ * @param len
|
|
|
+ * 数字长度
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getRandomNumber(int len) {
|
|
|
+ int max = (int) Math.pow(10, len) - 1;
|
|
|
+ int min = (int) Math.pow(10, len - 1);
|
|
|
+ return String.valueOf(new Random().nextInt(max) % (max - min + 1) + min);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|