Skip to content

Instantly share code, notes, and snippets.

@ar-android
Created September 21, 2017 14:58
Show Gist options
  • Save ar-android/67bc185d4201e91e69120536f699bacc to your computer and use it in GitHub Desktop.
Save ar-android/67bc185d4201e91e69120536f699bacc to your computer and use it in GitHub Desktop.
/*
* Return user short name
* */
public static String getShortName(String name) {
String[] strings = name.split(" ");//no i18n
String shortName;
if (strings.length == 1) {
shortName = strings[0].substring(0, 2);
} else {
shortName = strings[0].substring(0, 1) + strings[1].substring(0, 1);
}
return shortName.toUpperCase();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment