Java日期转中文大写
1 2 3 public class zhuanhuan { 4 5 /** 大写数字 */ 6 7 private static final String[] NUMBERS = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }; 8 9 private static final String[] data = { "年","月","日"}; 10 11 /** 通过 yyyy-MM-dd 得到中文大写格式 yyyy MM dd 日期 */ 12 13 public static synchronized String toChinese(String str) { 14 15 StringBuffer sb = new StringBuffer(); 16 17 sb.append(getSplitDateStr(str, 0)).append(" ").append( 18 19 getSplitDateStr(str, 1)).append(" ").append( 20 21 getSplitDateStr(str, 2)); 22 23 return sb.toString(); 24 25 } 26 27 public static String getSplitDateStr(String str,int num){ 28 29 String[] DateStr = str.split("-"); 30 31 StringBuffer sb = new StringBuffer(); 32 33 for(int i=0;i<DateStr[num].length();i++){ 34 35 sb.append(countnum(DateStr[num].substring(i, i + 1))); 36 37 } 38 39 return sb.append(data[num]).toString(); 40 41 } 42 43 public static String countnum(String num){ 44 45 return NUMBERS[Integer.valueOf(num)]; 46 47 } 48 49 public static void main(String args[]) { 50 51 System.out.println(toChinese("2008-10-02")); 52 53 } 54 55 } 56 57
JAVA js JQurey EasyUI nodejs 等随笔

浙公网安备 33010602011771号