26 lines
627 B
Java
26 lines
627 B
Java
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;
|
||
}
|
||
}
|