Skip to content

Instantly share code, notes, and snippets.

@aorborc
Last active February 15, 2024 20:19
Show Gist options
  • Save aorborc/c092c25dc0d78a93b2f562247a09455d to your computer and use it in GitHub Desktop.
Save aorborc/c092c25dc0d78a93b2f562247a09455d to your computer and use it in GitHub Desktop.
Convert Indian currency value to a readable comma separate value in Zoho Creator
string FormatIndianCurrency(float currency_val)
{
number = "";
frac_value = "";
if(currency_val != null)
{
if(currency_val > 0.0)
{
// whole_value = "12345678";
whole_value = currency_val.toString().getPrefix(".");
separator = 3;
visit = 0;
str_len = whole_value.length();
st_ind = str_len - 1;
end_ind = str_len;
counter = leftpad("1",str_len).replaceAll(" ","1,").toList();
for each index i in counter
{
visit = visit + 1;
number = number + whole_value.substring(st_ind,end_ind);
if(visit == separator && st_ind != 0)
{
number = number + ",";
separator = 2;
visit = 0;
}
st_ind = st_ind - 1;
end_ind = end_ind - 1;
}
frac_value = "." + currency_val.toString().getSuffix(".");
}
}
return number.reverse() + frac_value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment