Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generates mail like: name.surname@example.com
public static String generateMail(String name, String surname) {
String[] searchList = {"ä", "ö", "ü", "ß"};
String[] replaceList = {"ae", "oe", "ue", "ss"};
String mailAddress = StringUtils.defaultIfBlank(StringUtils.lowerCase(name, Locale.GERMAN), "vorname") + "." + StringUtils.defaultIfBlank(StringUtils.lowerCase(surname, Locale.GERMAN), "nachname");
mailAddress = mailAddress.replace(" ", "-");
mailAddress = StringUtils.replaceEachRepeatedly(mailAddress, searchList, replaceList);
return StringUtils.stripAccents(mailAddress) + Constants.DEFAULT_MAIL_DOMAIN;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment