单位转换类UnitUtil2
package com.jlb.scan.util; import java.math.BigDecimal;
import java.text.DecimalFormat; import com.jlb.mobile.common.utils.StringUtil; /**
* 单位转换
*
*/
public class UnitUtil2 {
public static float convertG2KG(String numInG) {
if (StringUtil.isEmpty(numInG)) {
return 0f;
} if (!NumberUtil.isRealNumber(numInG)) {
return 0f;
} return new BigDecimal(convertDigital2Str(numInG)).movePointLeft(3).floatValue();
} public static String convertDigital2Str(String number) {
if (StringUtil.isEmpty(number)) {
return null;
}
DecimalFormat format = new DecimalFormat("#0.00");
return format.format(new BigDecimal(number).doubleValue());
} public static float convertCent2Dollar(String money) {
if (StringUtil.isEmpty(money)) {
return 0;
} BigDecimal decimal = new BigDecimal(convertDigital2Str(money));
return decimal.movePointLeft(2).floatValue();
} public static float convertCent2Dollar(float money) {
BigDecimal decimal = new BigDecimal(convertDigital2Str(money));
return decimal.movePointLeft(2).floatValue(); } public static String convertDigital2Str(float number) {
DecimalFormat format = new DecimalFormat("#0.00");
return format.format(number);
} public static String convertKG2GStr(String numInKG) {
if (StringUtil.isEmpty(numInKG)) {
return "0";
} if (!NumberUtil.isRealNumber(numInKG)) {
return null;
} return new BigDecimal(convertDigital2Str(numInKG)).movePointRight(3).toString();
}
}
单位转换类UnitUtil2的更多相关文章
- Revit API单位转换类
用法:txt.Text=UnitConvertC.CovertFromAPI(param.AsDouble());param.Set(UnitConvertC.CovertToAPI(txt.Text ...
- Android 尺寸单位转换和屏幕适配相关
Android 尺寸单位转换和屏幕适配相关 各种尺寸单位的意义 dp: Density-independent Pixels 一个抽象的单元,基于屏幕的物理密度. (dp和dip的意义相同,所以不用区 ...
- spring-boot前端参数单位转换
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import ja ...
- Android屏幕尺寸单位转换
最近在看Android群英传这本书,书中有一节涉及到了,屏幕尺寸与单位.觉得以后可能会用到,做个笔记. PPI(pixels per inch) ,又称为DPI,它是由对角线的像素点数除以屏幕的大小得 ...
- Android原生系统API自带dp、px、sp单位转换
Android系统中自带的Api中可以使用TypedValue进行单位转换 1,调用系统api转换单位 // 获得转换后的px值 float pxDimension = TypedValue.appl ...
- DataTable与DTO对象的简易转换类
在web开发过程中,有时候为了数据传输的方便,比如:后台需要更新前端的ViewModel,此时我们定义一个与前端ViewModel结构一样的DTO对象,从数据层获取数据后,将数据封装成DTO然后序列化 ...
- System.currentTimeMillis()计算方式与时间的单位转换
目录[-] 一.时间的单位转换 二.System.currentTimeMillis()计算方式 一.时间的单位转换 1秒=1000毫秒(ms) 1毫秒=1/1,000秒(s)1秒=1,000,000 ...
- 日期转换类 DateConverter.java
package com.util; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.D ...
- C# 网络通信大小端转换类
本篇文章主要介绍了"C# 网络通信大小端转换类" using System;namespace Framework.NetPackage.Common { /// <summ ...
随机推荐
- 柱状图多系列php动态实现(ec)
<?php require_once 'data.php'; $arr1=$a->sum('answer','ask_id=1'); $arr2=$a->sum('answer',' ...
- python入门基本知识
1. 什么是语言 语言是一个事物与另外一个事物沟通的介质. python则是人(程序员)与计算机沟通的介质. 2. 什么是编程 编程就是程序员将自己想要让计算机做的事情用编程语言翻译出来写到一系列的文 ...
- Linux基础知识与命令1(su passwd)
一.Linux的基本原则 1.linux由一个个目的单一的小程序组成,我们一般需要组合小程序来完成复杂的任务 2.Linux的一切都是文件(文件类似于一棵树,包括外设,接口) 3.Linux尽量避免捕 ...
- 17-比赛2 F - Fox And Two Dots (dfs)
Fox And Two Dots CodeForces - 510B ================================================================= ...
- python向多个邮箱发邮件--注意接收是垃圾邮件
群发邮件注意:三处标红的地方 # -*- coding: UTF-8 -*- import smtplib from email.mime.text import MIMEText from emai ...
- 开启虚拟机所报的错误:VMware Workstation cannot connect to the virtual machine. Make sure you have rights to run the program, access all directories the program uses, and access all directories for temporary fil
当我们开启虚拟机时出现错误: VMware Workstation cannot connect to the virtual machine. Make sure you have rights t ...
- Hyper-V 安装Windows 2008,08 R2,12 R2 无网卡驱动的解决办法
最近玩 Hyper -V ,都是在网上找的资料进行操作的.后面发觉园友提供的一些操作 按部就班的做下来,别人 可以 ,我的就是不行. 最近就遇到一个很烦闷的事情.(如题) 安装好系统之后 发现 没有网 ...
- mongodb安装和配置三步走
最近在重新学习node,所以和同事一起搞了个模仿新浪微博的项目,项目刚开始,所以其他的东西就暂时先不提.这里介绍下mongodb的安装.直接搜索可以看到很多介绍,但是我第一次是失败了,不过看了好几个还 ...
- Python学习-前台开发-ajax操作
概述 对于WEB应用程序:用户浏览器发送请求,服务器接收并处理请求,然后返回结果,往往返回就是字符串(HTML),浏览器将字符串(HTML)渲染并显示浏览器上. 1.传统的Web应用 一个简单操作需要 ...
- express常用代码片段
请求模块: var express = require('express'); var router = express.Router(); // 拿到express框架的路由 var mongoos ...