StrUtils.java 1018 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * *************************************************
  3. * Copyright (c) 2018 QMTH. All Rights Reserved.
  4. * Created by Deason on 2018-07-23 15:05:46.
  5. * *************************************************
  6. */
  7. package cn.com.qmth.examcloud.app.utils;
  8. import java.util.Random;
  9. import java.util.UUID;
  10. public class StrUtils {
  11. public static String uuid() {
  12. return UUID.randomUUID().toString().replaceAll("-", "");
  13. }
  14. public static Integer randomNumber() {
  15. return randomNumber(100000, 999999);
  16. }
  17. public static int randomNumber(int min, int max) {
  18. Random random = new Random();
  19. return random.nextInt(max) % (max - min + 1) + min;
  20. }
  21. /**
  22. * 校验手机号码格式
  23. */
  24. public static boolean isMobile(String str) {
  25. return check(str, "^[1][3,4,5,6,7,8,9][0-9]{9}$");
  26. }
  27. public static boolean check(String str, String reg) {
  28. if (str != null && str.matches(reg)) {
  29. return true;
  30. }
  31. return false;
  32. }
  33. }