Copy the code code as follows:
/**
* Convert RMB to uppercase letters
*
* @param value
* @return String
*/
public static String hangeToBig(double value)
{
char[] hunit = { '十', '百', '千' }; // Position representation within the segment
char[] vunit = { '10,000', '100 million' }; // Representation of segment name
char[] digit = {'zero', 'one', 'two', 'three', 'four', 'five', 'Lu', 'Qi', 'eight', 'Nine' }; // Number express
long midVal = (long) (value * 100); // Convert to integer
String valStr = String.valueOf(midVal); //Convert to string
String head = valStr.substring(0, valStr.length() - 2); // Take the integer part
String rail = valStr.substring(valStr.length() - 2); // Take the decimal part
String prefix = ""; // The result of the integer part conversion
String suffix = ""; // The result of the decimal part conversion
// Process the numbers after the decimal point
if (rail.equals("00"))
{ // If the decimal part is 0
suffix = "whole";
}
else
{
suffix = digit[rail.charAt(0) - '0'] + "angle" + digit[rail.charAt(1) - '0'] + "minute"; // Otherwise, convert angle minutes out
}
// Process the number before the decimal point
char[] chDig = head.toCharArray(); // Convert the integer part into a character array
char zero = '0'; // Flag '0' indicates that 0 has occurred
byte zeroSerNum = 0; // Number of consecutive occurrences of 0
for (int i = 0; i < chDig.length; i++)
{ // Loop through each number
int idx = (chDig.length - i - 1) % 4; // Get the position within the segment
int vidx = (chDig.length - i - 1) / 4; // Get segment position
if (chDig[i] == '0')
{ // If the current character is 0
zeroSerNum++; // Increment 0 consecutive times
if (zero == '0')
{ // flag
zero = digit[0];
}
else if (idx == 0 && vidx > 0 && zeroSerNum < 4)
{
prefix += vunit[vidx - 1];
zero = '0';
}
continue;
}
zeroSerNum = 0; // Clear 0 consecutive times
if (zero != '0')
{ // If the flag is not 0, add, for example, tens of thousands, billions, etc.
prefix += zero;
zero = '0';
}
prefix += digit[chDig[i] - '0']; // Convert the digital representation
if (idx > 0)
prefix += hunit[idx - 1];
if (idx == 0 && vidx > 0)
{
prefix += vunit[vidx - 1]; // The segment name should be added to the end of the segment, such as ten thousand, billion
}
}
if (prefix.length() > 0)
prefix += 'circle'; // If the integer part exists, there will be the word circle
return prefix + suffix; // Return the correct representation
}