package com.zhongma.people.car.fitting.tool;
import java.util.Random;
public class RandomTool {
private static String[] YEAR = new String[]{
"1979", "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989",
"1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000",
"2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011",
"2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022"
};
private static String[] MONTH = new String[]{"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};
private static String[] DATE = new String[]{
"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14",
"15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28"
};
private static String[] NUM_WORD = new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "X"};
private static String[] MONTH_ARR = new String[]{"2019", "2020", "2021", "2022", "2023"};
public static int randomIndex(int bound) {
Random random = new Random();
return random.nextInt(bound);
}
public static String randomBirthday() {
StringBuilder sb = new StringBuilder();
int index = randomIndex(YEAR.length);
sb.append(YEAR[index]);
index = randomIndex(MONTH.length);
sb.append(MONTH[index]);
index = randomIndex(DATE.length);
sb.append(DATE[index]);
return sb.toString();
}
public static Integer randomMonth() {
StringBuilder sb = new StringBuilder();
int index = randomIndex(MONTH_ARR.length);
sb.append(MONTH_ARR[index]);
index = randomIndex(MONTH.length);
sb.append(MONTH[index]);
return Integer.parseInt(sb.toString());
}
public static String randomIdCardNum(String[] area) {
int index = randomIndex(area.length);
StringBuilder sb = new StringBuilder();
sb.append(area[index]);
index = randomIndex(NUM_WORD.length - 1);
sb.append(NUM_WORD[index]);
index = randomIndex(NUM_WORD.length - 1);
sb.append(NUM_WORD[index]);
sb.append(randomBirthday());
index = randomIndex(NUM_WORD.length - 1);
sb.append(NUM_WORD[index]);
index = randomIndex(NUM_WORD.length - 1);
sb.append(NUM_WORD[index]);
index = randomIndex(2);
sb.append(NUM_WORD[index]);
index = randomIndex(NUM_WORD.length);
sb.append(NUM_WORD[index]);
return sb.toString();
}
public static String getSex(String idCardNum) {
String sex = idCardNum.substring(16, 17);
int i = Integer.parseInt(sex);
if (i % 2 == 0) {
return "2";
}
return "1";
}
}