2018-06-03 22:26:41 +08:00

26 lines
627 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.amarsoft.app.accounting.print;
import java.text.DecimalFormat;
/*
* @author lwan 2010.09.08
* 将double型保留两位小数转换成字符数组并逆序返回
* 例如输入1275.125466得到315721
* @return char[]
* */
public class NumberToBit {
public static char[] getToBit(double d){
char[] sbit=null;
DecimalFormat df=new DecimalFormat("#.00");
StringBuffer sb=new StringBuffer(df.format(d));
String newstr=sb.reverse().toString();
int i=newstr.indexOf(".");
String s1=newstr.substring(0, i);
String s2=newstr.substring(i+1);
String realstr=s1+s2;
sbit=realstr.toCharArray();
return sbit;
}
}