This one could not be the more efficient solution but works
public static String substring(String s, int byteLimit) {
if (s.getBytes().length <= byteLimit) {
return s;
}
int n = Math.min(byteLimit-1, s.length()-1);
do {
s = s.substring(0, n--);
} while (s.getBytes().length > byteLimit);
return s;
}