如何在java中将数字转换为泰语单词
Posted
技术标签:
【中文标题】如何在java中将数字转换为泰语单词【英文标题】:how to convert numeric to thai language word in java 【发布时间】:2015-01-05 05:57:44 【问题描述】:我使用了以下代码,但它不起作用
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】:我想你想要
System.out.println("word : "+outputString);
在 for 循环之外并使其等同于:http://docs.oracle.com/javase/tutorial/i18n/locale/create.html 删除“word :”。即:
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);
【讨论】:
以上是关于如何在java中将数字转换为泰语单词的主要内容,如果未能解决你的问题,请参考以下文章
在 ruby 中将数字转换为单词 - 改进我的递归解决方案