Skip to content

Commit

Permalink
Utils.truncate
Browse files Browse the repository at this point in the history
  • Loading branch information
brmeyer committed Jun 28, 2024
1 parent d5502c0 commit 3787fd1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/impactupgrade/nucleus/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public static String trim(String s) {
return s.trim();
}

public static String truncate(String s, int maxChars) {
return s.length() > maxChars ? s.substring(0, maxChars - 1) + "..." : s;
}

public static String lowercase(String s) {
if (s == null) return null;
return s.toLowerCase(Locale.ROOT);
Expand Down

0 comments on commit 3787fd1

Please sign in to comment.