Skip to content

Commit 7a9f0c2

Browse files
committed
Backport: $pad function to truncate fractional part of numeric argument
Original commit: jsonata-js/jsonata@09dba37
1 parent f29a6f8 commit 7a9f0c2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/java/com/dashjoin/jsonata/Functions.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ public static String trim(String str) {
561561
* @param {string} [char] - the pad character(s); defaults to ' '
562562
* @returns {string} - padded string
563563
*/
564-
public static String pad(String str, Integer width, String _char) {
564+
public static String pad(String str, Number _width, String _char) {
565565
// undefined inputs always return undefined
566566
if (str == null) {
567567
return null;
@@ -572,6 +572,7 @@ public static String pad(String str, Integer width, String _char) {
572572
}
573573

574574
String result;
575+
int width = _width.intValue();
575576

576577
if (width < 0) {
577578
result = leftPad(str, -width, _char);

0 commit comments

Comments
 (0)