[AppleScript] 纯文本查看 复制代码
import java.util.Scanner;
class Demo
{
public static void judge(String s) {
String[] str=s.split("-");
int year=Integer.parseInt(str[0]);//年
int month=Integer.parseInt(str[1]);//月
int day=Integer.parseInt(str[2]);//日
int num=month*30+day;//懒得算了,直接以每月三十天为准
String week="";
switch(num%7) {
case 1:
week="星期一";
break;
case 2:
week="星期二";
break;
case 3:
week="星期三";
break;
case 4:
week="星期四";
break;
case 5:
week="星期五";
break;
case 6:
week="星期六";
break;
case 0:
week="星期日";
break;
}
System.out.println(str[0]+"年-"+str[1]+"月-"+str[2]+"日是"+week+",是"+str[0]+"年的第"+num+"天");
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("日期格式(2015-10-20)");
String date=sc.nextLine();
judge(date);
}
}