1. 程式人生 > >阿拉伯數字轉漢語數字(100以內)

阿拉伯數字轉漢語數字(100以內)

position從“1”開始

 public static String ChineseDate(String position) {
        String str;
        String[] s1 = new String[]{"","一", "二", "三", "四", "五", "六", "七", "八", "九", "十"};
        if (position.length() < 2) {
            str = s1[Integer.valueOf(position)];
        } else {
            String bit = position.substring(0, 1);
            String ten = position.substring(1, 2);
            if (ten.equals("0")) {
                str = s1[Integer.valueOf(bit) ] + s1[10];
            } else {
                str = s1[Integer.valueOf(bit)] + s1[10] + s1[Integer.valueOf(ten)];
            }
        }
        return "第" + str + "期";
    }