Converting Numbers to Local (UTF8) Bengali numbers in JasperReports & MySQL

前端 未结 2 380
野性不改
野性不改 2021-01-13 22:18

I am trying to convert the English numbers to Bengali numbers before filling the report. The data i am getting from MySQL:

SELECT brand.id,brand.brand,model.         


        
2条回答
  •  一向
    一向 (楼主)
    2021-01-13 22:51

    You also could create a replacement String in the Java code and use it in the parameters map:

       String replacedOne = one.getText().replaceAll("0","০").replaceAll("1","১").replaceAll("2","২").replaceAll("3","৩").replaceAll("4","৪").replaceAll("5","৫").replaceAll("6","৬").replaceAll("7","৭").replaceAll("8","৮").replaceAll("9","৯");
       parameters.put("replacedID",replacedOne);
    

    Or better, you can perform the replacement directly in your jrxml file, with no need to modify the java file, by using this (very long) expression instead of $F{model}:

    $F{model}.replaceAll("0","০").replaceAll("1","১").replaceAll("2","২").replaceAll("3","৩").replaceAll("4","৪").replaceAll("5","৫").replaceAll("6","৬").replaceAll("7","৭").replaceAll("8","৮").replaceAll("9","৯");
    

提交回复
热议问题