• 【java工具类】自定义规则生成类似真实邮箱


    这里需要添加一个maven依赖

    <!-- https://mvnrepository.com/artifact/cn.hutool/hutool-core -->
    <dependency>
    	<groupId>cn.hutool</groupId>
    	<artifactId>hutool-all</artifactId>
    	<version>5.8.4</version>
    </dependency>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    工具类自取,最近有这种需求,花了点时间弄了这个工具类:

    package com.ruoyi.module.utils;
    
    import cn.hutool.extra.pinyin.PinyinUtil;
    
    /**
     * 随机数生成工具类
     * @author xiongdingkun
     * @version 1.0
     */
    public class RandomValueUtil {
    
        private static final String NUMBER_BASE = "0123456789";
        private static final String ENGLISH_BASE = "abcdefghijklmnopqrstuvwxyz";
        private static final String FIRSTNAME = "赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄和穆萧尹姚邵湛汪祁毛禹狄米贝明臧计伏成戴谈宋茅庞熊纪舒屈项祝董梁杜阮蓝闵席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田樊胡凌霍虞万支柯咎管卢莫经房裘缪干解应宗宣丁贲邓郁单杭洪包诸左石崔吉钮龚程嵇邢滑裴陆荣翁荀羊於惠甄魏加封芮羿储靳汲邴糜松井段富巫乌焦巴弓牧隗山谷车侯宓蓬全郗班仰秋仲伊宫宁仇栾暴甘钭厉戎祖武符刘姜詹束龙叶幸司韶郜黎蓟薄印宿白怀蒲台从鄂索咸籍赖卓蔺屠蒙池乔阴郁胥能苍双闻莘党翟谭贡劳逄姬申扶堵冉宰郦雍却璩桑桂濮牛寿通边扈燕冀郏浦尚农温别庄晏柴瞿阎充慕连茹习宦艾鱼容向古易慎戈廖庚终暨居衡步都耿满弘匡国文寇广禄阙东殴殳沃利蔚越夔隆师巩厍聂晁勾敖融冷訾辛阚那简饶空曾毋沙乜养鞠须丰巢关蒯相查后江红游竺权逯盖益桓公万俟司马上官欧阳夏侯诸葛闻人东方赫连皇甫尉迟公羊澹台公冶宗政濮阳淳于仲孙太叔申屠公孙乐正轩辕令狐钟离闾丘长孙慕容鲜于宇文司徒司空亓官司寇仉督子车颛孙端木巫马公西漆雕乐正壤驷公良拓拔夹谷宰父谷粱晋楚阎法汝鄢涂钦段干百里东郭南门呼延归海羊舌微生岳帅缑亢况后有琴梁丘左丘东门西门商牟佘佴伯赏南宫墨哈谯笪年爱阳佟第五言福百家姓续";
        private static final String GIRL = "秀娟英华慧巧美娜静淑惠珠翠雅芝玉萍红娥玲芬芳燕彩春菊兰凤洁梅琳素云莲真环雪荣爱妹霞香月莺媛艳瑞凡佳嘉琼勤珍贞莉桂娣叶璧璐娅琦晶妍茜秋珊莎锦黛青倩婷姣婉娴瑾颖露瑶怡婵雁蓓纨仪荷丹蓉眉君琴蕊薇菁梦岚苑婕馨瑗琰韵融园艺咏卿聪澜纯毓悦昭冰爽琬茗羽希宁欣飘育滢馥筠柔竹霭凝晓欢霄枫芸菲寒伊亚宜可姬舒影荔枝思丽 ";
        private static final String BOY = "伟刚勇毅俊峰强军平保东文辉力明永健世广志义兴良海山仁波宁贵福生龙元全国胜学祥才发武新利清飞彬富顺信子杰涛昌成康星光天达安岩中茂进林有坚和彪博诚先敬震振壮会思群豪心邦承乐绍功松善厚庆磊民友裕河哲江超浩亮政谦亨奇固之轮翰朗伯宏言若鸣朋斌梁栋维启克伦翔旭鹏泽晨辰士以建家致树炎德行时泰盛雄琛钧冠策腾楠榕风航弘";
        private static final String[] EMAIL_SUFFIX = "@gmail.com,@yahoo.com,@msn.com,@hotmail.com,@aol.com,@ask.com,@live.com,@qq.com,@0355.net,@163.com,@163.net,@263.net,@3721.net,@yeah.net,@googlemail.com,@126.com,@sina.com,@sohu.com,@yahoo.com.cn".split(",");
        private static final String[] SYMBOL = new String[]{"-", "_"};
        private static final String[] TEL_FIRST = "134,135,136,137,138,139,150,151,152,157,158,159,130,131,132,155,156,133,153".split(",");
        private static final Integer RANDOM_NUMBER = 1;
        private static final Integer INITIAL_RANDOM_NUMBER = 2;
        private static final Integer QQ_RANDOM_NUMBER = 3;
        private static final Integer NAME_PINYIN = 4;
        private static final Integer TELEPHONE_NUMBER = 5;
        private static final Integer NAME_PLUS_YEAR = 6;
        private static final Integer ENGLISH_NAME_PLUS_RANDOM_ENGLISH_LETTERS = 7;
        private static final Integer INITIALS_PLUS_BIRTHDAY = 8;
    
        /**
         * 获得指定区间的随机数
         * 公式是rand.nextInt(max-min+1)+min
         * @param start 开始数
         * @param end 结束数
         * @return int
         */
        public static int getNum(int start, int end) {
            return (int) (Math.random() * (end - start + 1) + start);
        }
    
        /**
         * 随机生成Email
         * @return String
         */
        public static String getEmail() {
            StringBuilder sb = new StringBuilder();
            int randomNumber = getNum(1, 8);
            if (randomNumber == RANDOM_NUMBER) {
                //纯随机数(不能是0开头)
                sb.append(getNum(1, 9));
                sb.append(RandomValueUtil.getNumber(8, 11));
            } else if (randomNumber == INITIAL_RANDOM_NUMBER) {
                //名字首字母加随机数
                sb.append(PinyinUtil.getFirstLetter(getChineseName(), ""));
                sb.append(RandomValueUtil.getNumber(5, 7));
            } else if (randomNumber == QQ_RANDOM_NUMBER) {
                //qq+随机数
                sb.append("qq" + RandomValueUtil.getNumber(8, 10));
            } else if (randomNumber == NAME_PINYIN) {
                //名字拼音
                sb.append(PinyinUtil.getPinyin(getChineseName(), ""));
                sb.append(RandomValueUtil.getNumber(0, 2));
            } else if (randomNumber == TELEPHONE_NUMBER) {
                //电话号码
                sb.append(RandomValueUtil.getTelephone());
            } else if (randomNumber == NAME_PLUS_YEAR) {
                //名字加年份
                sb.append(PinyinUtil.getPinyin(getChineseName(), ""));
                sb.append(getRandomYear());
            } else if (randomNumber == ENGLISH_NAME_PLUS_RANDOM_ENGLISH_LETTERS) {
                //英文名加随机英文字母
                int symbolNumber = getNum(0, 1);
                sb.append(getEnglishName() + SYMBOL[symbolNumber] + getEnglish(2, 3));
            } else if (randomNumber == INITIALS_PLUS_BIRTHDAY) {
                //首字母加生日
                sb.append(PinyinUtil.getFirstLetter(getChineseName(), ""));
                sb.append(RandomLocalDate.randomDateTime());
            }
            sb.append(EMAIL_SUFFIX[(int) (Math.random() * EMAIL_SUFFIX.length)]);
            return sb.toString();
        }
    
        /***
         * 随机生成英文
         * @return String
         */
        public static String getEnglish(int lMin, int lMax) {
            int length = getNum(lMin, lMax);
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < length; i++) {
                int number = (int) (Math.random() * ENGLISH_BASE.length());
                sb.append(ENGLISH_BASE.charAt(number));
            }
            return sb.toString();
        }
    
        /***
         * 随机生成随机数
         * @return String
         */
        public static String getNumber(int lMin, int lMax) {
            int length = getNum(lMin, lMax);
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < length; i++) {
                int number = (int) (Math.random() * NUMBER_BASE.length());
                sb.append(NUMBER_BASE.charAt(number));
            }
            return sb.toString();
        }
    
        /***
         * 随机生成随机英文名
         * @return String
         */
        public static String getEnglishName() {
            StringBuilder sb = new StringBuilder();
            int number = (int) (Math.random() * SourceEn.namesEn.length);
            sb.append(SourceEn.namesEn[number]);
            return sb.toString();
        }
    
        /***
         * 随机生成手机号码
         * @return String
         */
        public static String getTelephone() {
            int index = getNum(0, TEL_FIRST.length - 1);
            String first = TEL_FIRST[index];
            String second = String.valueOf(getNum(1, 888) + 10000).substring(1);
            String thrid = String.valueOf(getNum(1, 9100) + 10000).substring(1);
            return first + second + thrid;
        }
    
        /***
         * 随机生成8位电话号码
         * @return String
         */
        public static String getLandline() {
            int index = getNum(0, TEL_FIRST.length - 1);
            String first = TEL_FIRST[index];
            String second = String.valueOf(getNum(1, 888) + 10000).substring(1);
            String thrid = String.valueOf(getNum(1, 9100) + 10000).substring(1);
            return first + second + thrid;
        }
    
        /**
         * 获取随机的年份
         * @return Integer
         */
        public static Integer getRandomYear() {
            int max = 2022;
            int min = 1970;
            return getNum(1970, 2022);
        }
    
        /***
         * 返回中文姓名
         * @return String
         */
        public static String getChineseName() {
            String nameSex = "";
            int index = getNum(0, FIRSTNAME.length() - 1);
            String first = FIRSTNAME.substring(index, index + 1);
            int sex = getNum(0, 1);
            String str = BOY;
            int length = BOY.length();
            if (sex == 0) {
                str = GIRL;
                length = GIRL.length();
                nameSex = "女";
            } else {
                nameSex = "男";
            }
            index = getNum(0, length - 1);
            String second = str.substring(index, index + 1);
            int hasThird = getNum(0, 1);
            String third = "";
            if (hasThird == 1) {
                index = getNum(0, length - 1);
                third = str.substring(index, index + 1);
            }
            return first + second + third;
        }
    
        public static void main(String[] args) {
            for (int i = 0; i < 1000; i++) {
                System.out.println(getEmail());
            }
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189

    名字常量类:

    package com.ruoyi.module.utils;
    
    public class SourceEn {
    
        public static String[] namesEn = {
                "Aaron",
                "Abel",
                "Abraham",
                "Adam",
                "Adrian",
                "Aidan",
                "Alva",
                "Alex",
                "Alexander",
                "Alan",
                "Albert",
                "Alfred",
                "Andrew",
                "Andy",
                "Angus",
                "Anthony",
                "Apollo",
                "Arnold",
                "Arthur",
                "August",
                "Austin",
                "Ben",
                "Benjamin",
                "Bert",
                "Benson",
                "Bill",
                "Billy",
                "Blake",
                "Bob",
                "Bobby",
                "Brad",
                "Brandon",
                "Brant",
                "Brent",
                "Brian",
                "Brown",
                "Bruce",
                "Caleb",
                "Cameron",
                "Carl",
                "Carlos",
                "Cary",
                "Caspar",
                "Cecil",
                "Charles",
                "Cheney",
                "Chris",
                "Christian",
                "Christopher",
                "Clark",
                "Cliff",
                "Cody",
                "Cole",
                "Colin",
                "Cosmo",
                "Daniel",
                "Denny",
                "Darwin",
                "David",
                "Dennis",
                "Derek",
                "Dick",
                "Donald",
                "Douglas",
                "Duke",
                "Dylan",
                "Eddie",
                "Edgar",
                "Edison",
                "Edmund",
                "Edward",
                "Edwin",
                "Elijah",
                "Elliott",
                "Elvis",
                "Eric",
                "Ethan",
                "Eugene",
                "Evan",
                "Enterprise",
                "Ford",
                "Francis",
                "Frank",
                "Franklin",
                "Fred",
                "Gabriel",
                "Gaby",
                "Garfield",
                "Gary",
                "Gavin",
                "Geoffrey",
                "George",
                "Gino",
                "Glen",
                "Glendon",
                "Hank",
                "Hardy",
                "Harrison",
                "Harry",
                "Hayden",
                "Henry",
                "Hilton",
                "Hugo",
                "Hunk",
                "Howard",
                "Henry",
                "Ian",
                "Ignativs",
                "Ivan",
                "Isaac",
                "Isaiah",
                "Jack",
                "Jackson",
                "Jacob",
                "James",
                "Jason",
                "Jay",
                "Jeffery",
                "Jerome",
                "Jerry",
                "Jesse",
                "Jim",
                "Jimmy",
                "Joe",
                "John",
                "Johnny",
                "Jonathan",
                "Jordan",
                "Jose",
                "Joshua",
                "Justin",
                "Keith",
                "Ken",
                "Kennedy",
                "Kenneth",
                "Kenny",
                "Kevin",
                "Kyle",
                "Lance",
                "Larry",
                "Laurent",
                "Lawrence",
                "Leander",
                "Lee",
                "Leo",
                "Leonard",
                "Leopold",
                "Leslie",
                "Loren",
                "Lori",
                "Lorin",
                "Louis",
                "Luke",
                "Marcus",
                "Marcy",
                "Mark",
                "Marks",
                "Mars",
                "Marshal",
                "Martin",
                "Marvin",
                "Mason",
                "Matthew",
                "Max",
                "Michael",
                "Mickey",
                "Mike",
                "Nathan",
                "Nathaniel",
                "Neil",
                "Nelson",
                "Nicholas",
                "Nick",
                "Noah",
                "Norman",
                "Oliver",
                "Oscar",
                "Owen",
                "Patrick",
                "Paul",
                "Peter",
                "Philip",
                "Phoebe",
                "Quentin",
                "Randall",
                "Randolph",
                "Randy",
                "Ray",
                "Raymond",
                "Reed",
                "Rex",
                "Richard",
                "Richie",
                "Riley",
                "Robert",
                "Robin",
                "Robinson",
                "Rock",
                "Roger",
                "Ronald",
                "Rowan",
                "Roy",
                "Ryan",
                "Sam",
                "Sammy",
                "Samuel",
                "Scott",
                "Sean",
                "Shawn",
                "Sidney",
                "Simon",
                "Solomon",
                "Spark",
                "Spencer",
                "Spike",
                "Stanley",
                "Steve",
                "Steven",
                "Stewart",
                "Stuart",
                "Terence",
                "Terry",
                "Ted",
                "Thomas",
                "Tim",
                "Timothy",
                "Todd",
                "Tommy",
                "Tom",
                "Thomas",
                "Tony",
                "Tyler",
                "Ultraman",
                "Ulysses",
                "Van",
                "Vern",
                "Vernon",
                "Victor",
                "Vincent",
                "Warner",
                "Warren",
                "Wayne",
                "Wesley",
                "William",
                "Willy",
                "Zack",
                "Zachary",
                "Abigail",
                "Abby",
                "Ada",
                "Adelaide",
                "Adeline",
                "Alexandra",
                "Ailsa",
                "Aimee",
                "Alexis",
                "Alice",
                "Alicia",
                "Alina",
                "Allison",
                "Alyssa",
                "Amanda",
                "Amy",
                "Amber",
                "Anastasia",
                "Andrea",
                "Angel",
                "Angela",
                "Angelia",
                "Angelina",
                "Ann",
                "Anna",
                "Anne",
                "Annie",
                "Anita",
                "Ariel",
                "April",
                "Ashley",
                "Audrey",
                "Aviva",
                "Barbara",
                "Barbie",
                "Beata",
                "Beatrice",
                "Becky",
                "Bella",
                "Bess",
                "Bette",
                "Betty",
                "Blanche",
                "Bonnie",
                "Brenda",
                "Brianna",
                "Britney",
                "Brittany",
                "Camille",
                "Candice",
                "Candy",
                "Carina",
                "Carmen",
                "Carol",
                "Caroline",
                "Carry",
                "Carrie",
                "Cassandra",
                "Cassie",
                "Catherine",
                "Cathy",
                "Chelsea",
                "Charlene",
                "Charlotte",
                "Cherry",
                "Cheryl",
                "Chloe",
                "Chris",
                "Christina",
                "Christine",
                "Christy",
                "Cindy",
                "Claire",
                "Claudia",
                "Clement",
                "Cloris",
                "Connie",
                "Constance",
                "Cora",
                "Corrine",
                "Crystal",
                "Daisy",
                "Daphne",
                "Darcy",
                "Dave",
                "Debbie",
                "Deborah",
                "Debra",
                "Demi",
                "Diana",
                "Dolores",
                "Donna",
                "Dora",
                "Doris",
                "Edith",
                "Editha",
                "Elaine",
                "Eleanor",
                "Elizabeth",
                "Ella",
                "Ellen",
                "Ellie",
                "Emerald",
                "Emily",
                "Emma",
                "Enid",
                "Elsa",
                "Erica",
                "Estelle",
                "Esther",
                "Eudora",
                "Eva",
                "Eve",
                "Evelyn",
                "Fannie",
                "Fay",
                "Fiona",
                "Flora",
                "Florence",
                "Frances",
                "Frederica",
                "Frieda",
                "Flta",
                "Gina",
                "Gillian",
                "Gladys",
                "Gloria",
                "Grace",
                "Grace",
                "Greta",
                "Gwendolyn",
                "Hannah",
                "Haley",
                "Hebe",
                "Helena",
                "Hellen",
                "Henna",
                "Heidi",
                "Hillary",
                "Ingrid",
                "Isabella",
                "Ishara",
                "Irene",
                "Iris",
                "Ivy",
                "Jacqueline",
                "Jade",
                "Jamie",
                "Jane",
                "Janet",
                "Jasmine",
                "Jean",
                "Jenna",
                "Jennifer",
                "Jenny",
                "Jessica",
                "Jessie",
                "Jill",
                "Joan",
                "Joanna",
                "Jocelyn",
                "Joliet",
                "Josephine",
                "Josie",
                "Joy",
                "Joyce",
                "Judith",
                "Judy",
                "Julia",
                "Juliana",
                "Julie",
                "June",
                "Karen",
                "Karida",
                "Katherine",
                "Kate",
                "Kathy",
                "Katie",
                "Katrina",
                "Kay",
                "Kayla",
                "Kelly",
                "Kelsey",
                "Kimberly",
                "Kitty",
                "Lareina",
                "Lassie",
                "Laura",
                "Lauren",
                "Lena",
                "Lydia",
                "Lillian",
                "Lily",
                "Linda",
                "lindsay",
                "Lisa",
                "Liz",
                "Lora",
                "Lorraine",
                "Louisa",
                "Louise",
                "Lucia",
                "Lucy",
                "Lucine",
                "Lulu",
                "Lydia",
                "Lynn",
                "Mabel",
                "Madeline",
                "Maggie",
                "Mamie",
                "Manda",
                "Mandy",
                "Margaret",
                "Mariah",
                "Marilyn",
                "Martha",
                "Mavis",
                "Mary",
                "Matilda",
                "Maureen",
                "Mavis",
                "Maxine",
                "May",
                "Mayme",
                "Megan",
                "Melinda",
                "Melissa",
                "Melody",
                "Mercedes",
                "Meredith",
                "Mia",
                "Michelle",
                "Milly",
                "Miranda",
                "Miriam",
                "Miya",
                "Molly",
                "Monica",
                "Morgan",
                "Nancy",
                "Natalie",
                "Natasha",
                "Nicole",
                "Nikita",
                "Nina",
                "Nora",
                "Norma",
                "Nydia",
                "Octavia",
                "Olina",
                "Olivia",
                "Ophelia",
                "Oprah",
                "Pamela",
                "Patricia",
                "Patty",
                "Paula",
                "Pauline",
                "Pearl",
                "Peggy",
                "Philomena",
                "Phoebe",
                "Phyllis",
                "Polly",
                "Priscilla",
                "Quentina",
                "Rachel",
                "Rebecca",
                "Regina",
                "Rita",
                "Rose",
                "Roxanne",
                "Ruth",
                "Sabrina",
                "Sally",
                "Sandra",
                "Samantha",
                "Sami",
                "Sandra",
                "Sandy",
                "Sarah",
                "Savannah",
                "Scarlett",
                "Selma",
                "Selina",
                "Serena",
                "Sharon",
                "Sheila",
                "Shelley",
                "Sherry",
                "Shirley",
                "Sierra",
                "Silvia",
                "Sonia",
                "Sophia",
                "Stacy",
                "Stella",
                "Stephanie",
                "Sue",
                "Sunny",
                "Susan",
                "Tamara",
                "Tammy",
                "Tanya",
                "Tasha",
                "Teresa",
                "Tess",
                "Tiffany",
                "Tina",
                "Tonya",
                "Tracy",
                "Ursula",
                "Vanessa",
                "Venus",
                "Vera",
                "Vicky",
                "Victoria",
                "Violet",
                "Virginia",
                "Vita",
                "Vivian"
        };
    
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257
    • 258
    • 259
    • 260
    • 261
    • 262
    • 263
    • 264
    • 265
    • 266
    • 267
    • 268
    • 269
    • 270
    • 271
    • 272
    • 273
    • 274
    • 275
    • 276
    • 277
    • 278
    • 279
    • 280
    • 281
    • 282
    • 283
    • 284
    • 285
    • 286
    • 287
    • 288
    • 289
    • 290
    • 291
    • 292
    • 293
    • 294
    • 295
    • 296
    • 297
    • 298
    • 299
    • 300
    • 301
    • 302
    • 303
    • 304
    • 305
    • 306
    • 307
    • 308
    • 309
    • 310
    • 311
    • 312
    • 313
    • 314
    • 315
    • 316
    • 317
    • 318
    • 319
    • 320
    • 321
    • 322
    • 323
    • 324
    • 325
    • 326
    • 327
    • 328
    • 329
    • 330
    • 331
    • 332
    • 333
    • 334
    • 335
    • 336
    • 337
    • 338
    • 339
    • 340
    • 341
    • 342
    • 343
    • 344
    • 345
    • 346
    • 347
    • 348
    • 349
    • 350
    • 351
    • 352
    • 353
    • 354
    • 355
    • 356
    • 357
    • 358
    • 359
    • 360
    • 361
    • 362
    • 363
    • 364
    • 365
    • 366
    • 367
    • 368
    • 369
    • 370
    • 371
    • 372
    • 373
    • 374
    • 375
    • 376
    • 377
    • 378
    • 379
    • 380
    • 381
    • 382
    • 383
    • 384
    • 385
    • 386
    • 387
    • 388
    • 389
    • 390
    • 391
    • 392
    • 393
    • 394
    • 395
    • 396
    • 397
    • 398
    • 399
    • 400
    • 401
    • 402
    • 403
    • 404
    • 405
    • 406
    • 407
    • 408
    • 409
    • 410
    • 411
    • 412
    • 413
    • 414
    • 415
    • 416
    • 417
    • 418
    • 419
    • 420
    • 421
    • 422
    • 423
    • 424
    • 425
    • 426
    • 427
    • 428
    • 429
    • 430
    • 431
    • 432
    • 433
    • 434
    • 435
    • 436
    • 437
    • 438
    • 439
    • 440
    • 441
    • 442
    • 443
    • 444
    • 445
    • 446
    • 447
    • 448
    • 449
    • 450
    • 451
    • 452
    • 453
    • 454
    • 455
    • 456
    • 457
    • 458
    • 459
    • 460
    • 461
    • 462
    • 463
    • 464
    • 465
    • 466
    • 467
    • 468
    • 469
    • 470
    • 471
    • 472
    • 473
    • 474
    • 475
    • 476
    • 477
    • 478
    • 479
    • 480
    • 481
    • 482
    • 483
    • 484
    • 485
    • 486
    • 487
    • 488
    • 489
    • 490
    • 491
    • 492
    • 493
    • 494
    • 495
    • 496
    • 497
    • 498
    • 499
    • 500
    • 501
    • 502
    • 503
    • 504
    • 505
    • 506
    • 507
    • 508
    • 509
    • 510
    • 511
    • 512
    • 513
    • 514
    • 515
    • 516
    • 517
    • 518
    • 519
    • 520
    • 521
    • 522
    • 523
    • 524
    • 525
    • 526
    • 527
    • 528
    • 529
    • 530
    • 531
    • 532
    • 533
    • 534
    • 535
    • 536
    • 537
    • 538
    • 539
    • 540
    • 541
    • 542
    • 543
    • 544
    • 545
    • 546
    • 547
    • 548
    • 549
    • 550
    • 551
    • 552
    • 553
    • 554
    • 555
    • 556
    • 557
    • 558
    • 559
    • 560
    • 561
    • 562
    • 563
    • 564
    • 565
    • 566
    • 567
    • 568
    • 569
    • 570
    • 571
    • 572
    • 573
    • 574
    • 575
    • 576
    • 577

    时间工具类:

    package com.ruoyi.module.utils;
    
    import java.time.LocalDate;
    import java.time.format.DateTimeFormatter;
    import java.util.Random;
    
    public class RandomLocalDate {
    
        public static final LocalDate minDate = LocalDate.of(1980, 1, 1);
    
        private static final LocalDate maxDate= LocalDate.of(2000, 1, 1);
    
        /**
         * 指定日期随机年月日
         * @return
         */
        public static String randomDateTime() {
            int minDay = (int) minDate.toEpochDay();
            int maxDay = (int) maxDate.toEpochDay();
            Random random = new Random();
            long randomDay = minDay + random.nextInt(maxDay - minDay);
            LocalDate localDate = LocalDate.ofEpochDay(randomDay);
            return localDate.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
  • 相关阅读:
    frp远程运维技术
    31-k8s集群svc的代理模式-iptables修改为ipvs
    Python - 小玩意 - html 转 pdf
    wininet,winhttp,xmlhttprequest,各版本区别 《转》
    mysql数据库,字符串使用双引号““导致报错,使用单引号‘‘不报错,Unknown column ‘user-test‘ in ‘where clause‘
    精选版:用Java扩展Nginx(nginx-clojure 入门)
    Centos7安装单机版Kafka
    Ant-design-vue组件上传文档
    数组的最长递减子序列
    树莓派+RTL-SDR 搭建APRS iGATE
  • 原文地址:https://blog.csdn.net/qq_42275749/article/details/126143784