Skip to content

Instantly share code, notes, and snippets.

@arslan-gg
Created September 2, 2021 10:15
Show Gist options
  • Save arslan-gg/28dca48fcd4ca303fb6c75d81cea22b2 to your computer and use it in GitHub Desktop.
Save arslan-gg/28dca48fcd4ca303fb6c75d81cea22b2 to your computer and use it in GitHub Desktop.
Trim string value in Java
public String trim(String value, int maxLength) {
return value.substring(0, Math.min(value.length(), maxLength));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment