「java发票代码」java实现电子发票
今天给各位分享java发票代码的知识,其中也会对java实现电子发票进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
- 1、用Java实现模拟发票的打印,输入123.45,输出壹佰贰拾叁元肆角五分,输入123,输出壹佰贰拾
- 2、上传发票java.lang.exception怎么解决
- 3、java 发票代码如何实现
- 4、一道Java编程题 求源代码
用Java实现模拟发票的打印,输入123.45,输出壹佰贰拾叁元肆角五分,输入123,输出壹佰贰拾
/**
* 数字金额大写转换,思想先写个完整的然后将如零拾替换成零
* 要用到正则表达式
*/
public static String digitUppercase(double n){
String fraction[] = {"角", "分"};
String digit[] = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
String unit[][] = {{"元", "万", "亿"},
{"", "拾", "佰", "仟"}};
String head = n 0? "负": "";
n = Math.abs(n);
String s = "";
for (int i = 0; i fraction.length; i++) {
s += (digit[(int)(Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
}
if(s.length()1){
s = "整";
}
int integerPart = (int)Math.floor(n);
for (int i = 0; i unit[0].length integerPart 0; i++) {
String p ="";
for (int j = 0; j unit[1].length n 0; j++) {
p = digit[integerPart%10]+unit[1][j] + p;
integerPart = integerPart/10;
}
s = p.replaceAll("(零.)*零$", "").replaceAll("^$", "零") + unit[0][i] + s;
}
return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整");
}
上传发票java.lang.exception怎么解决
解决办法:在方法里加上参数注解 @RequestParam这个错误是在使用wangEditor配置多文件上传的时候出现的,使用单个文件上传没有这个问题。直接使用多文件上传一直报错,就用了单文件循环。代码如下:
public static Map uploadFilesForWEditor(@RequestParam("files")MultipartFile[] files,HttpServletRequest request,HttpServletResponse response){
Map map=new HashMap();
List url = new ArrayList();
for (int i = 0; i 0){
map.put("errno",0);
map.put("msg","上传成功");
map.put("data",url);
}else{
map.put("errno",1);
map.put("msg","上传失败");
ma.put("data",url);
}
return map;
}
```
FileUploadUtils:
```java
public static String fileUpload(MultipartFile file,HttpServletRequest request,HttpServletResponse response){
//获取图片的原名字
String oldName=file.getOriginalFilename();
String timeName=System.currentTimeMillis()+"_";
String newName=timeName+oldName;
//获取项目的路径 在项目路径下新建文件夹
Strng path= "D:/uploadFile";
//新建 uploadFile 文件夹
File parentPath=new File(path);
if(!parentPath.exists()){
parentPath.mkdirs();}
String src="";
try {
file.transferTo(new File(parentPath,newName));
File theFile=new File(parentPath+"/"+newName);
if(theFile.exists()){
//拼接图片的相对路径作为URL
src="/"+newName;
}else{
src="";
}
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return src;
java 发票代码如何实现
开发出一个页面,前台div+css+jquery即可,后台取值存表根据不同的发票模板显示数据给前台读取,具体的发票头,金额,发票内容等等input自己输入
一道Java编程题 求源代码
public class Invoice {
String bianhao = null;
String shuoming = null;
int count = 0;
double price = 0.0;
public Invoice(String bianhao, String shuoming, int count, double price) {
this.bianhao = bianhao;
this.shuoming = shuoming;
if (count 0) {
this.count = 0;
} else {
this.count = count;
}
if (price 0.0) {
this.price = 0.0;
} else {
this.price = price;
}
}
public double getInvoiceAmount() {
return count * price;
}
public String getBianhao() {
return bianhao;
}
public void setBianhao(String bianhao) {
this.bianhao = bianhao;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String getShuoming() {
return shuoming;
}
public void setShuoming(String shuoming) {
this.shuoming = shuoming;
}
}
public class InvoiceTest {
/**
* @param args
*/
public static void main(String[] args) {
Invoice invoice = new Invoice("010220", "Desk", 50, 53.9);
System.out.println(invoice.getInvoiceAmount());
}
}
关于java发票代码和java实现电子发票的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
发布于:2022-11-28,除非注明,否则均为
原创文章,转载请注明出处。