当前位置:网站首页>BigDecimel转人民币大写
BigDecimel转人民币大写
2022-07-25 08:24:00 【t梧桐树t】
BigDecimel对象,转换成人民币大写字样
/**
* pdf显示中文大写金额
*
* @param bigDecimal
* @return
*/
public static String bigDecimalToLocalStr(BigDecimal bigDecimal) {
BigDecimal resultBigDecimal = CalculationUtils.add(bigDecimal, BigDecimal.ZERO, 2);
String[] chinese = new String[]{"", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "万"};
String[] numChinese = new String[]{"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
String[] afterChinese = new String[]{"角", "分"};
String str = String.valueOf(resultBigDecimal);
String[] arr = str.split("\\.");
char[] chars = arr[0].toCharArray();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < chars.length; ++i) {
sb.append(numChinese[Integer.valueOf(String.valueOf(chars[i])).intValue()]).append(chinese[chars.length - i - 1]);
}
if (arr.length == 1) {
return sb.toString() + "元整";
} else if (arr[1].length() > 2) {
throw new BusinessException(Constants.SERVICE_VERIFY_EXCEPTION_CODE, "人民币大写转换BigDecimal只能保留2位小数");
} else {
sb.append("元");
char[] chars1 = arr[1].toCharArray();
for (int i = 0; i < chars1.length; ++i) {
sb.append(numChinese[Integer.valueOf(String.valueOf(chars1[i])).intValue()]).append(afterChinese[i]);
}
return sb.toString();
}
}
}边栏推荐
- Redis best practices
- 一次简单的SQL注入靶场练习
- efcore在Saas系统下多租户零脚本分表分库读写分离解决方案
- Advanced C language (11) - user defined data types
- @Principle of Autowired annotation
- @Implementation principle of Autowired annotation
- Vscode remote connection server, switch to go version
- Didi - dispatching
- 第3章业务功能开发(查询线索)
- nuscenes数据集3D MOT demo,端到端的目标检测和跟踪,检测跟踪联合框架
猜你喜欢

Data warehouse ODS, DWD floor, 220616, HM,

CentOS 8.2 MySQL installation (xshell6)
![[dark horse programmer] redis learning notes 001: introduction to redis + five basic data types](/img/f7/9f43cd964a671f3b53337999332280.png)
[dark horse programmer] redis learning notes 001: introduction to redis + five basic data types

【万字长文】使用 LSM-Tree 思想基于.Net 6.0 C# 实现 KV 数据库(案例版)

A simple SQL injection shooting range exercise

一款强大的端口扫描工具(nmap)

Introduction to machine learning (I): understanding maximum likelihood estimation in supervised learning

475-82(230、43、78、79、213、198、1143)
![[dark horse programmer] redis learning notes 005: enterprise level solutions](/img/76/959d18994ab9eb170cbdbdccbe94e7.png)
[dark horse programmer] redis learning notes 005: enterprise level solutions

第3章业务功能开发(实现全选按钮实时的响应)
随机推荐
Chapter 3 business function development (realize the real-time response of the select all button)
Dirty data and memory leakage of ThreadLocal
node+js搭建时间服务器
[dark horse programmer] redis learning notes 004: master-slave replication + sentinel mode + cluster
Interview questions: common faults and occurrence scenarios of redis
【黑马程序员】Redis学习笔记001:Redis简介+五种基本数据类型
@Autowired注解的原理
C#入门系列(三十) -- 异常处理
【keras bug】Tensor is unhashable if Tensor equality is enabled. Instead, use tensor.experimental_ ref(
第3章业务功能开发(实现全选按钮实时的响应)
Some easy-to-use plug-ins and settings installed in vscode
Database query optimization
A simple hotel background management system based on jsp+servlet+mysql
Learn when playing No 5 | human high quality examination, right here →
Redis最佳实践
Raspberry pie uses the command line to configure WiFi connections
Surpassing transformer, Tsinghua, byte significantly refresh parallel text generation SOTA performance | ICML 2022
[ffmpeg] MP4 to YUV
【黑马程序员】Redis学习笔记005:企业级解决方案
Redis学习