Convert string amount to currency format in the specified format

Source: Internet
Author: User

Objective

When doing financial projects, a large number of contacts of digital strings often need to be formatted to display, here I wrote a demo, the string amount is formatted, you can retain the number of decimal digits, you can add a currency identifier prefix.

Written in the prototype string, you need to format the right time to format the chant!

Example: ' 123345.23123 '. Moneyformatter (2, ' ¥ ')

Output: ' ¥123,345.23 '

The demo has a comment, so I don't have to do any more explaining.

My demo
<! DOCTYPE html>Brief introduction

Accept two parameters, N and current, do not pass the process, if you want to pass in the specified order, first pass n,n to need to retain a few decimals, and then pass the current as if you want to add a currency prefix directly into!

Method internal default is the standard Money presentation form, 3 bit a ', ', will no longer be flexible control of parameters!

Convert string amount to currency format in the specified format

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.