Fixed #11. Added support for last function

This commit is contained in:
Shekhar Gulati
2016-05-20 20:03:33 +05:30
parent 6986e34fd3
commit 08945f3d04
2 changed files with 23 additions and 0 deletions
+15
View File
@@ -515,6 +515,21 @@ public abstract class Strman {
return Objects.equals(value, value.toLowerCase());
}
/**
* Return the last n chars of String
*
* @param value The input String
* @param n Number of chars to return
* @return n Last characters
*/
public static String last(final String value, int n) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
if (n > value.length()) {
return value;
}
return value.substring(value.length() - n);
}
public static String leftPad(final String value, final String pad, final int length) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
if (value.length() >= length) {