File tree Expand file tree Collapse file tree
src/main/java/io/github/intisy/utils/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ public static String encrypt(String password) {
7777 throw new RuntimeException (e );
7878 }
7979 }
80-
80+
8181 public static List <String > splitString (String string ) {
8282 List <String > result = new ArrayList <>();
8383 StringBuilder line = new StringBuilder ();
@@ -96,4 +96,25 @@ public static List<String> splitString(String string) {
9696 }
9797 return result ;
9898 }
99+
100+ public static String toTitleCase (String input ) {
101+ if (input == null || input .isEmpty ()) {
102+ return input ;
103+ }
104+
105+ String [] words = input .split (" " );
106+ StringBuilder titleCase = new StringBuilder ();
107+
108+ for (String word : words ) {
109+ if (word .length () > 1 ) {
110+ titleCase .append (Character .toUpperCase (word .charAt (0 )))
111+ .append (word .substring (1 ).toLowerCase ());
112+ } else {
113+ titleCase .append (word .toUpperCase ());
114+ }
115+ titleCase .append (" " );
116+ }
117+
118+ return titleCase .toString ().trim ();
119+ }
99120}
You can’t perform that action at this time.
0 commit comments