Try this:import java.util.*;
import java.text.*;public class ShowDay { java.util.Date dt = new java.util.Date();
public ShowDay() {
Calendar c = new GregorianCalendar().getInstance();
// c = new GregorianCalendar(2005,2,19);
// c = new GregorianCalendar(2005,2,20);
String str_english = new SimpleDateFormat("今年是yyyy年MMMd日 E").format(c.getTime());
String str_chinese = convertDate(str_english);
System.out.print(
str_english+"\n"
+str_chinese+"\n"
);
}
public static String convertDate(String string){
char[] n = new char[]{'零','一','二','三','四','五','六','七','八','九'};
char[] str = string.toCharArray();
for(int i = 0; i < str.length;i++){
try{
str[i] = n[Integer.parseInt(""+str[i])];
}catch(Exception e){}
}
return new String(str); }
public static void main(String args[]) {
ShowDay d = new ShowDay();
}
}
import java.text.*;public class ShowDay { java.util.Date dt = new java.util.Date();
public ShowDay() {
Calendar c = new GregorianCalendar().getInstance();
// c = new GregorianCalendar(2005,2,19);
// c = new GregorianCalendar(2005,2,20);
String str_english = new SimpleDateFormat("今年是yyyy年MMMd日 E").format(c.getTime());
String str_chinese = convertDate(str_english);
System.out.print(
str_english+"\n"
+str_chinese+"\n"
);
}
public static String convertDate(String string){
char[] n = new char[]{'零','一','二','三','四','五','六','七','八','九'};
char[] str = string.toCharArray();
for(int i = 0; i < str.length;i++){
try{
str[i] = n[Integer.parseInt(""+str[i])];
}catch(Exception e){}
}
return new String(str); }
public static void main(String args[]) {
ShowDay d = new ShowDay();
}
}
java.util.Date
dt = new java.util.Date();
String chi_dt;
public showday() {
String chi_dt;
int year = dt.getYear();
year += 1900;
int month = dt.getMonth();
month += 1;
int day = dt.getDay();
int date = dt.getDate();
String str_year = String.valueOf(year);
String str_month = String.valueOf(month);
String str_day = String.valueOf(day);
String str_date = String.valueOf(date);
String chi_num = "";
String chi_num_total = "";
char cha_i;
String chi_year = null;
String chi_month = null;
String chi_date = null;
String chi_day = null;
if (str_date.length() == 1) {
str_date = "0" + str_date; }
if (str_month.length() == 1) {
str_month = "0" + str_month; }
String str_i = str_year + str_month + str_date + str_day;
for (int j = 0; j < str_i.length(); j++) {
cha_i = str_i.charAt(j);
switch (cha_i) {
case '0':
chi_num = "O";
break;
case '1':
chi_num = "一";
break;
case '2':
chi_num = "二";
break;
case '3':
chi_num = "三";
break;
case '4':
chi_num = "四";
break;
case '5':
chi_num = "五";
break;
case '6':
chi_num = "六";
break;
case '7':
chi_num = "七";
break;
case '8':
chi_num = "八";
break;
case '9':
chi_num = "九";
break;
}
chi_num_total += chi_num;
if (j == 3) {
chi_year = chi_num_total;
chi_num_total = "";
}
if ( (j == 4) || (j == 6)) {
if ( (cha_i == '1') || (cha_i == '0')) if ( (cha_i == '0') || (cha_i == '1')) {
chi_num_total = "";
}
} if (j == 5) {
chi_month = chi_num_total;
chi_num_total = "";
}
if (j == 7) {
chi_date = chi_num_total;
chi_num_total = "";
} if (j == 8) {
if (cha_i == '0')
chi_num_total = "日"; chi_day = chi_num_total;
}
}
chi_dt = "今天是" + chi_year + "年" + chi_month + "月" + chi_date + "日" + "星期" +
chi_day; System.out.println(chi_dt);
}}public class myshowday {
public static void main(String args[]) {
showday d = new showday();
}
}
D:\j2sdk1.4.0_03\bin>java myshowday
今天是二OO五年三月三一日星期四
if ( (j == 4) || (j == 6)) {
if ( (cha_i == '1') || (cha_i == '0')) if ( (cha_i == '0') || (cha_i == '1')) {
chi_num_total = "";
}
}