substring
程序代码:
package dengdai;
public class wwqq {
public static void main(String[] args) {
String ss_1, ss_11, ss_111;
String ss_w[] = {"01/12/04", "02/13/04", "03/22/04", "04/21/04",
"05/26/04", "06/27/04", "07/28/04",
"08/29/04", "09/30/04", "10/31/04", };
for (int k = 0; k < ss_w.length; k++) {
ss_1 = ss_w[k].substring(0, 2); //求月份,调用substring方法
int m = Integer.parseInt(ss_1); //把月份强制转换成int,利于m和i比较
ss_11 = ss_w[k].substring(3, 5); //求号
ss_111 = ss_w[k].substring(6, 8); //求年
String StringArray[] = {" ", "January", "February ", "March",
"April ",
"May", "June ", "July", "August",
"September",
"October", "November", "December"};
//定义月份数组时候,StringArray[0]要定义为空,因为和m比较时候m>=1.
for (int i = 0; i <= StringArray.length; i++) {
if (m == i) {
ss_1 = StringArray[i]; //把对应的英文月份赋值给数字月份
System.out.println(ss_11 + "th" + " " + ss_1 + " " + "20" +
ss_111);
}
}
}
}