Java Regular Expression
Some useful java function that may help me in the java project
Generate random number of 10 digits
Get Current date into the specified format
Check given input string is numeric or not
Check given input string is alphabetic or not
Regular expression to validate email address
Regular expression to validate alphanumeric string
- Convert List of integer into any literal separated string
public static String joinList(List<Integer> list, String literal) {
return list.toString().replaceAll(",", literal).replaceAll("[\[.\].\s+]", "");
}
public static String randomNumber(){
Long randomNumber = (long) Math.floor(Math.random() * 9000000000L) + 1000000000L;
String number = Long.toString(randomNumber);
return number;
}
public static String currentDate(String dateFormat){
SimpleDateFormat s = new SimpleDateFormat(dateFormat);
Calendar cal = Calendar.getInstance();
return s.format(new Date(cal.getTimeInMillis()));
}
public static boolean isNumeric(String inputString) {
return inputString.matches("[-+]?\d*\.?\d+");
}
public static boolean isAlphabetic(String inputString) {
return inputString.matches("[a-zA-Z]+");
}
public static boolean isEmailFormat(String inputString) {
return inputString.matches("^[\w!#$%&'*+/=?`{|}~^-]+(?:\.[\w!#$%&'*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,6}$");
}
public static boolean isAlphaNumeric(String inputString) {
return inputString.matches("^[a-zA-Z0-9\s]*$");
}
Good contentcustomized erp solutions in india