如何在java中将数字转换为泰语单词

时间:2015-01-05 05:57:45

标签: java numbers word thai

我使用了以下代码但不起作用

import java.text.NumberFormat;
import java.util.Locale;

    public class NumToword {
       public static void main(String str[]){
            String outputString = new String();
           Locale[] thaiLocale = {
                        new Locale("th"),
                        new Locale("th", "TH"),
                        new Locale("th", "TH", "TH")
                    };
           for (Locale locale : thaiLocale) {
               NumberFormat nf = NumberFormat.getNumberInstance(locale);
               outputString = outputString + locale.toString() + ": ";
                outputString = outputString + nf.format(573.34) + "\n";
                System.out.println("word : "+outputString);
           }
       }
   }

1 个答案:

答案 0 :(得分:2)

我想你想要的     在for循环之外的System.out.println("word : "+outputString);并使其与:http://docs.oracle.com/javase/tutorial/i18n/locale/create.html相同,删除“word:”。 IE:

import java.text.NumberFormat;
import java.util.Locale;

public class NumToword {
   public static void main(String str[]){
        String outputString = new String();
       Locale[] thaiLocale = {
                    new Locale("th"),
                    new Locale("th", "TH"),
                    new Locale("th", "TH", "TH")
                };
       for (Locale locale : thaiLocale) {
           NumberFormat nf = NumberFormat.getNumberInstance(locale);
           outputString = outputString + locale.toString() + ": ";
            outputString = outputString + nf.format(573.34) + "\n";
       }
       System.out.println(outputString);
   }
  }