mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-13 10:31:03 +01:00
26 lines
538 B
Java
26 lines
538 B
Java
|
package nodomain.freeyourgadget.gadgetbridge.util;
|
||
|
|
||
|
public class StringUtils {
|
||
|
|
||
|
public static String truncate(String s, int maxLength){
|
||
|
int length = Math.min(s.length(), maxLength);
|
||
|
|
||
|
if(length < 0)
|
||
|
return "";
|
||
|
|
||
|
return s.substring(0, length);
|
||
|
}
|
||
|
|
||
|
public static String pad(String s, int length){
|
||
|
return pad(s, length, ' ');
|
||
|
}
|
||
|
|
||
|
public static String pad(String s, int length, char padChar){
|
||
|
|
||
|
while(s.length() < length)
|
||
|
s += padChar;
|
||
|
|
||
|
return s;
|
||
|
}
|
||
|
}
|